/* Ananta Tools — one design system for every page. Mobile-first, no web fonts, light + dark. */
:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #f0f2f8; --line: #e3e6ef; --line-strong: #cfd4e2;
  --text: #121726; --muted: #5a6275; --faint: #8a91a3;
  --brand: #4f46e5; --brand-ink: #3730a3; --brand-soft: #eef0ff; --on-brand: #ffffff;
  --ok: #0f8a4b; --ok-soft: #e6f6ed; --warn: #b45309; --warn-soft: #fff4e5; --err: #c0262d; --err-soft: #fdecec;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(18,23,38,.06), 0 4px 16px -8px rgba(18,23,38,.12);
  --max: 72rem; --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1017; --surface: #151a24; --surface-2: #1b2130; --line: #262e3f; --line-strong: #34405a;
    --text: #e8ebf3; --muted: #a3abbd; --faint: #7a8296;
    --brand: #8b84ff; --brand-ink: #b9b5ff; --brand-soft: #1f2141; --on-brand: #0d1017;
    --ok: #4cc98a; --ok-soft: #12291d; --warn: #f0b35a; --warn-soft: #2b2112; --err: #ff7b7f; --err-soft: #2c1517;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -10px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1017; --surface: #151a24; --surface-2: #1b2130; --line: #262e3f; --line-strong: #34405a;
  --text: #e8ebf3; --muted: #a3abbd; --faint: #7a8296;
  --brand: #8b84ff; --brand-ink: #b9b5ff; --brand-soft: #1f2141; --on-brand: #0d1017;
  --ok: #4cc98a; --ok-soft: #12291d; --warn: #f0b35a; --warn-soft: #2b2112; --err: #ff7b7f; --err-soft: #2c1517;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -10px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow-x: clip;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4.6vw, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.hdr { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.hdr .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 1.08rem; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 34px; height: 34px; flex: none; }
.logo b { color: var(--brand); font-weight: 800; }
.nav { display: none; margin-left: auto; gap: 4px; }
.nav a { color: var(--muted); font-weight: 600; font-size: .93rem; padding: 8px 12px; border-radius: 10px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); text-decoration: none; }
.hdr-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: 48px; width: min(92vw, 320px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.menu-panel a { display: flex; justify-content: space-between; padding: 11px 12px; border-radius: 10px; color: var(--text); font-weight: 600; }
.menu-panel a span { color: var(--faint); font-weight: 500; font-size: .85rem; }
.menu-panel a:hover { background: var(--surface-2); text-decoration: none; }
@media (min-width: 900px) { .nav { display: flex; } .hdr-actions { margin-left: 8px; } .menu { display: none; } }

/* ---------- Page ---------- */
main { padding: 20px 0 48px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .82rem; color: var(--faint); margin-bottom: 12px; padding: 0; list-style: none; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line-strong); }
.crumbs a { color: var(--muted); }
.page-head { margin-bottom: 18px; }
.page-head p.lead { color: var(--muted); font-size: 1.04rem; max-width: 52rem; margin-bottom: .75em; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 650; padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.badge svg { width: 14px; height: 14px; color: var(--ok); }

.grid-2 { display: grid; gap: 20px; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } .side { position: sticky; top: 76px; } }
.grid-2 > * { min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { padding: 20px; margin-top: 20px; }
@media (min-width: 640px) { .section { padding: 26px; } }
.section > :last-child { margin-bottom: 0; }

/* ---------- Tool (same shell for every tool) ---------- */
.tool { padding: 16px; }
@media (min-width: 640px) { .tool { padding: 22px; } }
.tool-step { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: .95rem; margin: 0 0 10px; }
.tool-step i { font-style: normal; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-size: .78rem; }
.tool-row { display: grid; gap: 18px; }
@media (min-width: 820px) { .tool-row.split { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } }
.tool-row > * { min-width: 0; }

.drop { position: relative; display: grid; place-items: center; text-align: center; gap: 6px; min-height: 180px; padding: 22px; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop svg { width: 40px; height: 40px; color: var(--brand); margin: 0 auto; }
.drop strong { font-size: 1.02rem; }
.drop small { color: var(--faint); }
.drop.compact { min-height: 96px; }

.fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
.field label, .field .lbl { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
textarea.input { min-height: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.5; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.hint { font-size: .78rem; color: var(--faint); margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip {
  min-height: 38px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: .86rem; font-weight: 650; cursor: pointer;
}
.seg button[aria-pressed="true"], .chip.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font: inherit; font-weight: 750; cursor: pointer; text-decoration: none !important; transition: transform .05s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.actions .btn { flex: 1 1 160px; }

.stage { position: relative; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 18px 18px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 220px; touch-action: none; user-select: none; }
.stage canvas { max-height: 60vh; width: auto; height: auto; }
.stage.crop canvas { cursor: grab; }
.stage .tip { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(13,16,23,.72); color: #fff; font-size: .74rem; padding: 4px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap; }

.result { margin-top: 16px; padding: 14px; border-radius: var(--radius); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.result[hidden] { display: none; }
.result .stats { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .9rem; margin-bottom: 10px; }
.result .stats b { font-size: 1.05rem; }
.result.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.msg { margin-top: 12px; padding: 10px 12px; border-radius: 10px; font-size: .9rem; background: var(--err-soft); color: var(--err); }
.msg[hidden] { display: none; }

.files { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.files li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: .9rem; }
.files li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.files li .sz { color: var(--faint); font-size: .8rem; white-space: nowrap; }
.files li button { border: 0; background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 1rem; }
.files li img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }

.out { width: 100%; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kv div { padding: 12px; border-radius: 12px; background: var(--surface-2); }
.kv dt { font-size: .75rem; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 2px 0 0; font-size: 1.3rem; font-weight: 800; }

/* ---------- Content ---------- */
.answer { border-left: 4px solid var(--brand); background: var(--brand-soft); padding: 14px 16px; border-radius: 0 12px 12px 0; margin: 20px 0 0; }
.answer p { margin: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-weight: 800; font-size: .85rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.tbl thead th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbl tr:last-child td { border-bottom: 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--faint); font-size: 1.3rem; line-height: 1; transition: transform .15s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 8px 0 0; color: var(--muted); }
.prose p, .prose li { color: var(--muted); }
.prose ul { padding-left: 1.2em; }
.prose strong { color: var(--text); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.tile .ic { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.tile .ic svg { width: 22px; height: 22px; }
.tile b { display: block; font-size: .98rem; }
.tile small { display: block; color: var(--muted); font-size: .83rem; line-height: 1.4; margin-top: 2px; }
.cat-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 32px 0 12px; }

.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(1.8rem, 6vw, 3rem); max-width: 22ch; }
.hero .lead { font-size: 1.08rem; color: var(--muted); max-width: 46rem; }
.search { position: relative; max-width: 560px; margin: 18px 0 14px; }
.search input { padding-left: 42px; min-height: 52px; border-radius: 14px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--faint); }

/* ---------- Ads (only rendered when a code is configured) ---------- */
.ad { margin: 22px 0; text-align: center; }
.ad::before { content: "Advertisement"; display: block; font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.ad-box { min-height: 250px; display: flex; justify-content: center; }
.ad-native { min-height: 120px; }
.ad iframe { border: 0; max-width: 100%; }

/* ---------- Footer ---------- */
.ftr { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 24px; font-size: .9rem; color: var(--muted); }
.ftr .cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.ftr h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.ftr ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.ftr a { color: var(--muted); }
.ftr .base { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; font-size: .82rem; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-weight: 650; font-size: .9rem; transition: transform .2s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
