/* Tools by 313bits — styles. Plain CSS, no build step.
   Brand tokens are copied from 313bits-site/public/assets/styles.css. */

:root {
  --bg: #f6f7f5;
  --bg-alt: #eef1ee;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #0f172a;
  --text: #334155;
  --muted: #5b6678;
  --border: #e2e7e4;
  --border-strong: #cfd7d3;
  --accent: #0f766e;
  --accent-hover: #0c625b;
  --accent-soft: #e3f2ef;
  --accent-ink: #0b5f58;
  --gold: #d4a017;
  --gold-soft: #fbf1d3;
  --gold-ink: #8a6508;
  --on-accent: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -6px rgba(15, 23, 42, .10);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 56px -12px rgba(15, 23, 42, .18);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --container: 1100px;
  --header-h: 60px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --bg-alt: #0e1628;
    --surface: #121b2e;
    --surface-2: #162036;
    --ink: #f1f5f9;
    --text: #cbd5e1;
    --muted: #94a3b8;
    --border: #223049;
    --border-strong: #2e3d59;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: rgba(45, 212, 191, .12);
    --accent-ink: #5eead4;
    --gold: #e9b93a;
    --gold-soft: rgba(233, 185, 58, .14);
    --gold-ink: #f3cd66;
    --on-accent: #042f2c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -8px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 28px 60px -14px rgba(0, 0, 0, .65);
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* .btn and friends set display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.025em; font-weight: 750; }
p { margin: 0 0 1em; }
a { color: var(--accent-ink); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -100px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; color: var(--bg); }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 18px; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 12px;
  font: 600 15px/1 var(--font); text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .12s;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.badge-soon { background: var(--gold-soft); color: var(--gold-ink); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner { height: var(--header-h); display: flex; align-items: center; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: -.03em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.wordmark { font-size: 17px; }
.wordmark span { color: var(--accent-ink); }
.brand-sub { font-size: 12px; font-weight: 650; color: var(--muted); border-left: 1px solid var(--border-strong); padding-left: 9px; margin-left: 1px; letter-spacing: 0; }
.header-spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: transparent; border: 1px solid transparent; color: var(--ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-ink); }
.page-title { font-size: 17px; font-weight: 750; color: var(--ink); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.by { display: inline-flex; align-items: center; gap: 7px; flex: none; font-size: 13px; font-weight: 650; color: var(--muted); text-decoration: none; padding: 6px 4px; }
.by img { border-radius: 6px; }
.by:hover { color: var(--accent-ink); }
@media (max-width: 380px) { .page-tool .by span { display: none; } }

/* ---------- home ---------- */
.hub-hero { position: relative; padding: 34px 0 18px; text-align: center; }
.hub-hero h1 { font-size: clamp(27px, 6.6vw, 42px); margin-bottom: 10px; position: relative; z-index: 1; }
.hub-hero .hl { color: var(--accent-ink); }
.hub-hero p { color: var(--muted); max-width: 46ch; margin: 0 auto; position: relative; z-index: 1; }
.glow {
  position: absolute; inset: -30px 0 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(42% 60% at 22% 30%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(38% 55% at 78% 25%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%);
  filter: blur(18px); opacity: .7;
}
.search { position: relative; max-width: 460px; margin: 18px auto 0; z-index: 1; }
.search .i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 14px 0 26px; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 3px;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
}
a.tool-card:hover, a.tool-card:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); color: inherit; }
.tool-card h2 { font-size: 15.5px; margin: 10px 0 0; letter-spacing: -.015em; }
.tool-card p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }
.tool-card.soon { opacity: .75; }
.tool-card .badge { position: absolute; top: 14px; right: 12px; }
.ticon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); }
.tool-card:nth-child(3n+2) .ticon { background: var(--gold-soft); color: var(--gold-ink); }
.no-match { text-align: center; color: var(--muted); padding: 10px 0 30px; }
@media (max-width: 420px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tool-card { padding: 12px; }
}

/* ---------- tool page ---------- */
.tool-main { padding: 18px 0 8px; }
.tool-head, .tool-box, .prose, .more-tools, .page-tool .ad-slot { max-width: 640px; margin-left: auto; margin-right: auto; }
.tool-head h1 { font-size: clamp(24px, 6vw, 32px); margin-bottom: 6px; }
.tool-head p { color: var(--muted); margin-bottom: 16px; }

.tool-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px; }
.tool-box + .tool-box { margin-top: 14px; }
.tool-box h2 { font-size: 16px; margin: 0 0 12px; }
@media (min-width: 560px) { .tool-box { padding: 20px; } }

.field { display: block; margin-bottom: 12px; min-width: 0; }
.field > span, .label { display: block; font-size: 13px; font-weight: 650; color: var(--ink); margin-bottom: 5px; }
.field small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.input, .field input, .field select, .field textarea, .search input {
  width: 100%; min-height: 48px; padding: 10px 13px;
  font: 500 16px/1.3 var(--font); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px;
  appearance: none; -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: right 18px top 21px, right 13px top 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field textarea { min-height: 180px; resize: vertical; line-height: 1.55; }
.search input { padding-left: 44px; }
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[type="date"] { display: block; -webkit-min-logical-width: calc(100% - 26px); }
.field input[type="range"] { padding: 0; min-height: 32px; background: none; border: 0; accent-color: var(--accent); appearance: auto; -webkit-appearance: auto; }
.field input[type="range"]:focus { box-shadow: none; }
.suffix { position: relative; }
.suffix input { padding-right: 52px; }
.suffix em { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-style: normal; font-weight: 650; color: var(--muted); font-size: 14px; pointer-events: none; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.row-auto { display: flex; gap: 10px; align-items: flex-end; }
.row-auto > .field { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  min-height: 38px; padding: 0 13px; border-radius: 999px;
  font: 600 14px/1 var(--font); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chip { flex: none; }

.result {
  margin-top: 6px; padding: 16px; border-radius: 14px;
  background: var(--accent-soft); color: var(--ink);
}
.result .label { color: var(--accent-ink); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 4px; }
.result .big { font-size: clamp(24px, 7vw, 32px); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result .sub { color: var(--text); margin: 6px 0 0; font-size: 14.5px; }
.result .sub:empty { display: none; }
.result.empty .big { color: var(--muted); font-size: 18px; font-weight: 600; letter-spacing: 0; }
.result-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); font-variant-numeric: tabular-nums; }
.result-line:first-of-type { border-top: 0; }
.result-line strong { color: var(--ink); text-align: right; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin-top: 12px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.stat span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat strong { display: block; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1 1 auto; }
.note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.note strong { color: var(--text); }
.warn { font-size: 13.5px; color: var(--gold-ink); background: var(--gold-soft); padding: 8px 12px; border-radius: 10px; margin: 10px 0 0; }

.tbl-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { font-size: 12px; color: var(--muted); font-weight: 650; background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.is-on td { background: var(--accent-soft); color: var(--ink); font-weight: 650; }

.split { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--gold); margin: 12px 0 6px; }
.split span { background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.swap { display: flex; justify-content: center; margin: -4px 0 8px; }
.swap .icon-btn { border-color: var(--border-strong); background: var(--surface); width: 40px; height: 40px; border-radius: 999px; }

/* ---------- ads: below the result, never between inputs and buttons ---------- */
.ad-slot { margin: 26px auto 0; }
.ad-slot[hidden] { display: none; }
.ad-slot .ad-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; text-align: center; }
.ad-slot ins { display: block; min-height: 100px; }
.hub-ad { max-width: 728px; margin-bottom: 8px; }

/* ---------- prose (explanation + FAQ: the SEO text) ---------- */
.prose { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--border); }
.prose h2 { font-size: 21px; margin-top: 28px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 16px; margin-top: 20px; margin-bottom: .3em; }
.prose ul, .prose ol { padding-left: 20px; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose code { font-size: .92em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 6px; }
.prose .tbl-wrap { margin-bottom: 1em; }

.more-tools { margin-top: 34px; }
.more-tools h2 { font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mini-card { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; min-width: 0; }
.mini-card span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .i { color: var(--accent-ink); }
.mini-card:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- legal pages ---------- */
.doc-main { padding: 24px 0 8px; }
.doc-main .prose { max-width: 70ch; margin: 0 auto; padding-top: 0; border-top: 0; }
.doc-main .meta { color: var(--muted); font-size: 14px; }
.not-found { text-align: center; padding: 40px 0 10px; }
.not-found .big { font-size: 64px; font-weight: 800; color: var(--accent-ink); line-height: 1; margin: 0 0 10px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-alt); padding: 26px 0 max(22px, env(safe-area-inset-bottom)); margin-top: 40px; font-size: 14px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 22px; }
.footer-brand p { color: var(--muted); font-size: 13px; max-width: 32ch; margin: 8px 0 0; }
.footer-col h2 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 5px; }
.footer-col a { color: var(--text); text-decoration: none; }
.footer-col a:hover { color: var(--accent-ink); text-decoration: underline; }
.footer-bottom { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; color: var(--muted); font-size: 12.5px; }
.footer-bottom p { margin: 0; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 16px); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast[data-open="true"] { opacity: 1; transform: translate(-50%, 0); }

/* ---------- tool specifics ---------- */
.hijri-today { text-align: center; }
.hijri-today .urdu { font-size: 22px; margin-top: 6px; }
.urdu { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", serif; direction: rtl; unicode-bidi: isolate; line-height: 2; }

.qr-out { display: grid; place-items: center; padding: 16px; margin-top: 4px; border-radius: 14px; background: #fff; border: 1px solid var(--border); }
.qr-out canvas { width: min(260px, 100%); height: auto; image-rendering: pixelated; }
.qr-out.empty canvas { opacity: .12; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 150px; padding: 18px; border-radius: 14px; cursor: pointer;
  border: 2px dashed var(--border-strong); background: var(--surface-2); color: var(--muted);
}
.drop:hover, .drop.is-over { border-color: var(--accent); color: var(--accent-ink); }
.drop strong { color: var(--ink); font-size: 16px; }
.drop .i { width: 28px; height: 28px; color: var(--accent-ink); }
.preview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.preview figure { margin: 0; min-width: 0; }
.preview img { width: 100%; height: 140px; object-fit: contain; background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--border) 0 50%) 0 0 / 16px 16px; border-radius: 10px; border: 1px solid var(--border); }
.preview figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.preview figcaption strong { color: var(--ink); }

.limits { display: grid; gap: 6px; margin-top: 12px; }
.limit { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13.5px; }
.limit .bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.limit .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.limit.over .bar i { background: #dc2626; }
.limit.over strong { color: #dc2626; }
.result-today { margin: 2px 0 0; }
.big-today { font-size: clamp(26px, 7.5vw, 34px); font-weight: 800; color: var(--ink); letter-spacing: -.03em; }
.hijri-today .row { text-align: left; margin-top: 14px; }
.hijri-today .note { text-align: left; }
.hijri-today #today-greg { text-align: center; margin: 0; }
.result .sub.urdu { font-size: 18px; }
.tbl-wrap .tbl.wrap td, .tbl-wrap .tbl.wrap th { white-space: normal; }
.tbl.wrap td:last-child { white-space: nowrap; }
.tbl.wrap td:nth-child(2) { color: var(--muted); font-size: 13px; }
