:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f1f1f8;
  --text: #16162a;
  --muted: #5b5b74;
  --border: #e2e2ee;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --accent: #0ea371;
  --warn: #c2410c;
  --chart-1: #4f46e5;
  --chart-2: #f59e0b;
  --chart-3: #0ea371;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 50, .06), 0 4px 16px rgba(20, 20, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f1a;
    --surface: #181826;
    --surface-2: #222235;
    --text: #ececf6;
    --muted: #a3a3bd;
    --border: #2d2d44;
    --primary: #818cf8;
    --primary-ink: #0f0f1a;
    --primary-soft: #23234a;
    --accent: #34d399;
    --warn: #fb923c;
    --chart-1: #818cf8;
    --chart-2: #fbbf24;
    --chart-3: #34d399;
    --shadow: none;
    color-scheme: dark;
  }
}
*, *::before, *::after { 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, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}
a { color: var(--primary); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .4em 0 .3em; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1.1rem; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 860px; }
.muted { color: var(--muted); }
.lead { font-size: 1.08rem; color: var(--muted); margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

/* Header & footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: var(--primary-ink); font-weight: 800; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.main-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 550; font-size: .95rem; }
.main-nav a:hover, .main-nav a[aria-current] { background: var(--primary-soft); color: var(--primary); }
.site-footer { margin-top: 64px; background: var(--surface); border-top: 1px solid var(--border); padding: 32px 0 16px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-grid a:not(.logo) { display: block; color: var(--muted); text-decoration: none; padding: 3px 0; }
.footer-grid a:hover { color: var(--primary); }
.footer-h { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.copyright { color: var(--muted); font-size: .85rem; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > div:first-child { grid-column: 1 / -1; } }

/* Home */
.hero { background: linear-gradient(180deg, var(--primary-soft), transparent); padding: 40px 0 16px; text-align: center; }
.hero .lead { max-width: 680px; margin: 0 auto 20px; }
.search input[type=search] { width: 100%; max-width: 560px; font-size: 1.05rem; padding: 14px 18px; border-radius: 999px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head a { text-decoration: none; font-weight: 600; white-space: nowrap; }
.home-about { margin-top: 32px; }

/* Tool cards */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.tool-card strong { display: block; }
.tool-card .muted { display: block; font-size: .9rem; line-height: 1.4; margin-top: 2px; }
.tool-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); font-size: 1.25rem; }

/* Breadcrumbs */
.crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); margin-top: 20px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--primary); }

/* Tool container & form controls */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 20px 0 8px; }
@media (max-width: 500px) { .tool { padding: 14px; } }
.privacy-note { font-size: .85rem; color: var(--muted); margin: 0 0 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span, .label { font-weight: 600; font-size: .92rem; }
.hint, .field > span.hint { font-size: .82rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=number], input[type=search], input[type=date], input[type=email], input[type=url], select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 18px; height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 0 16px 8px 0; font-size: .95rem; cursor: pointer; }
.input-affix { display: flex; align-items: stretch; }
.input-affix > span { display: grid; place-items: center; padding: 0 10px; background: var(--border); border-radius: 10px 0 0 10px; color: var(--muted); font-weight: 600; }
.input-affix > input { border-radius: 0 10px 10px 0; }
.btn { font: inherit; font-weight: 650; cursor: pointer; border: 0; border-radius: 10px; padding: 11px 18px; background: var(--primary); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--primary-soft); color: var(--primary); }
.btn.small { padding: 6px 12px; font-size: .88rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: inherit; font-size: .9rem; cursor: pointer; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.seg button[aria-pressed=true] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* Results */
.results { margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: .82rem; color: var(--muted); display: block; }
.stat .v { font-size: 1.3rem; font-weight: 750; display: block; word-break: break-word; }
.stat.hl { background: var(--primary-soft); }
.stat.hl .v { color: var(--primary); }
.out-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.out-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.out-item .txt { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; flex: 1; }
.out-item .meta { font-size: .78rem; color: var(--muted); display: block; margin-bottom: 2px; }
.output-box { background: var(--surface-2); border-radius: 10px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 48px; }
.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { background: var(--surface-2); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
.donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.donut { width: 140px; height: 140px; border-radius: 50%; flex: none; position: relative; }
.donut::after { content: ""; position: absolute; inset: 26%; border-radius: 50%; background: var(--surface); }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 160px; margin-top: 12px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column-reverse; min-width: 2px; height: 100%; }
.bar-chart .seg-a { background: var(--chart-1); border-radius: 0 0 2px 2px; }
.bar-chart .seg-b { background: var(--chart-3); border-radius: 2px 2px 0 0; }
.meter { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .2s; }
.meter.over > i { background: var(--warn); }
.limit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: .9rem; margin-bottom: 10px; }
.limit-row .meter { grid-column: 1 / -1; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 650; background: var(--primary-soft); color: var(--primary); }
.note { font-size: .85rem; color: var(--muted); }
.error { color: var(--warn); font-weight: 600; }
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 24px; text-align: center; cursor: pointer; background: var(--surface-2); }
.dropzone.drag { border-color: var(--primary); }
.preview { max-height: 360px; border-radius: 10px; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 50% / 20px 20px; display: block; margin: 12px auto 0; }
.hashtags { background: var(--surface-2); border-radius: 10px; padding: 14px; line-height: 1.9; overflow-wrap: anywhere; }
.script-block { border-left: 4px solid var(--primary); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 10px 14px; margin-bottom: 10px; }
.script-block .meta { font-size: .8rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.copied { background: var(--accent) !important; color: #fff !important; }

/* Article / guide content */
.prose { margin-top: 8px; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 4px 0; }
.prose table { margin: 12px 0; }
.prose .table-wrap table { margin: 0; }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.formula { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; overflow-x: auto; }
.faq { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 650; padding: 12px 0; }
.faq p { margin: 0 0 12px; }
.related { margin-top: 32px; }

[hidden] { display: none !important; }

/* Blog */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.post-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.post-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.post-card .badge { align-self: flex-start; }
.post-card strong { font-size: 1.05rem; line-height: 1.35; }
.post-card .muted { font-size: .92rem; line-height: 1.45; }
.post-meta { font-size: .85rem; color: var(--muted); }
.post-card .post-meta { margin-top: auto; }
.try-tool { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.try-tool a { background: var(--primary-soft); color: var(--primary); text-decoration: none; font-weight: 650; padding: 8px 14px; border-radius: 10px; }
.try-tool a:hover { filter: brightness(1.05); }
.callout { background: var(--primary-soft); border-radius: 12px; padding: 14px 16px; margin: 16px 0; }
.callout p { margin: 0; }

/* Blog images and charts */
.post-cover { display: block; width: 100%; height: auto; border-radius: var(--radius); margin: 8px 0 16px; }
.post-card img { width: 100%; height: auto; border-radius: 10px; margin-bottom: 4px; aspect-ratio: 1200 / 630; object-fit: cover; }
.chart { margin: 20px 0; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .lbl { fill: var(--text); font-size: 13px; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart figcaption { font-size: .88rem; color: var(--muted); margin-top: 8px; text-align: center; }
