/* Toolvik Pro — design system. Mobile first, light/dark, right-to-left aware. */

:root {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f3f4fa;
  --surface-3: #e9ebf5;
  --text: #0f1222;
  --text-2: #3a3f5c;
  --muted: #6a7090;
  --border: #e3e6f0;
  --border-strong: #c9cee0;
  --primary: #5b3df5;
  --primary-2: #7c5cff;
  --primary-ink: #ffffff;
  --primary-soft: rgba(91, 61, 245, .10);
  --accent: #10b5a3;
  --danger: #e0364f;
  --warn: #d98800;
  --ok: #0f9f6e;
  --grad: linear-gradient(135deg, #5b3df5 0%, #7c5cff 45%, #10b5a3 120%);
  --grad-soft: linear-gradient(135deg, rgba(91, 61, 245, .10), rgba(16, 181, 163, .10));
  --shadow-sm: 0 1px 2px rgba(15, 18, 34, .06);
  --shadow: 0 1px 2px rgba(15, 18, 34, .05), 0 6px 24px rgba(15, 18, 34, .06);
  --shadow-lg: 0 24px 60px rgba(38, 24, 120, .16);
  --ring: 0 0 0 4px rgba(91, 61, 245, .18);
  --radius-xl: 28px;
  --radius: 20px;
  --radius-sm: 14px;
  --header-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", "Noto Sans Devanagari",
    "Noto Sans Arabic", "Noto Sans Thai", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090b14; --bg-soft: #0e1120; --surface: #121527; --surface-2: #181c31; --surface-3: #20253f;
    --text: #eef0fb; --text-2: #c5c9e2; --muted: #9298b8; --border: #242944; --border-strong: #353b5e;
    --primary: #8b74ff; --primary-2: #a08cff; --primary-soft: rgba(139, 116, 255, .16); --accent: #2bd3c0;
    --grad-soft: linear-gradient(135deg, rgba(139, 116, 255, .16), rgba(43, 211, 192, .10));
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 28px rgba(0, 0, 0, .35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55); --ring: 0 0 0 4px rgba(139, 116, 255, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #090b14; --bg-soft: #0e1120; --surface: #121527; --surface-2: #181c31; --surface-3: #20253f;
  --text: #eef0fb; --text-2: #c5c9e2; --muted: #9298b8; --border: #242944; --border-strong: #353b5e;
  --primary: #8b74ff; --primary-2: #a08cff; --primary-soft: rgba(139, 116, 255, .16); --accent: #2bd3c0;
  --grad-soft: linear-gradient(135deg, rgba(139, 116, 255, .16), rgba(43, 211, 192, .10));
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55); --ring: 0 0 0 4px rgba(139, 116, 255, .25);
  color-scheme: dark;
}

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html.i18n-pending [data-i18n], html.i18n-pending .site-header, html.i18n-pending .site-footer, html.i18n-pending .js-fill { visibility: hidden; }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ic { width: 22px; height: 22px; flex-shrink: 0; display: block; }
svg { flex-shrink: 0; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 10px; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .35s ease both; }

/* ---------------- Header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 40; min-height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(91, 61, 245, .35); }
.brand-mark .ic { width: 20px; height: 20px; }
.header-search {
  flex: 1; max-width: 440px; margin-inline-start: 18px; display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); text-align: start;
}
.header-search span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-search kbd { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.header-search:hover { border-color: var(--border-strong); }
.header-actions { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.lang-btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 650; max-width: 180px; }
.lang-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-btn .ic { width: 20px; height: 20px; color: var(--muted); }
.lang-btn:hover { border-color: var(--border-strong); }
.only-mobile { display: none; }
@media (max-width: 760px) {
  .header-search { display: none; }
  .only-mobile { display: inline-grid; }
  .lang-btn { padding: 0 10px; max-width: 130px; }
}
@media (max-width: 420px) { .brand-name { display: none; } }

/* ---------------- Sheets (dialogs) ---------------- */
.save-body { display: flex; flex-direction: column; gap: 14px; padding: 4px 22px 22px; overflow-y: auto; }
.save-preview { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); -webkit-touch-callout: default; }
.save-text { margin: 4px 22px 22px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; resize: vertical; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px;
  background: rgba(8, 9, 20, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .18s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 580px; max-height: 84vh; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(.985); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 8px 22px; }
[dir="rtl"] .sheet-head { padding: 18px 22px 8px 16px; }
.sheet-title { font-size: 20px; font-weight: 800; }
.sheet-search { margin: 4px 16px 12px; height: 54px; padding: 0 18px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 17px; outline: none; }
.sheet-search:focus { border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); }
.lang-list, .result-list { overflow-y: auto; padding: 0 8px 12px; }
.lang-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px 18px; }
.lang-item { position: relative; display: flex; flex-direction: column; align-items: flex-start; text-align: start; min-height: 62px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.lang-item:hover { border-color: var(--primary); }
.lang-item.active { border-color: var(--primary); background: var(--primary-soft); }
.lang-native { font-weight: 700; font-size: 16px; }
.lang-en { font-size: 12.5px; color: var(--muted); }
.lang-check { position: absolute; inset-inline-end: 10px; top: 10px; color: var(--primary); }
.lang-check .ic { width: 18px; height: 18px; }
@media (max-width: 420px) { .lang-list { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .sheet-backdrop { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; max-height: 90vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.result-item { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--radius-sm); color: var(--text); }
.result-item:hover, .result-item:focus-visible, .result-item.active { background: var(--surface-2); text-decoration: none; }
.result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-name { font-weight: 700; }
.result-desc { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num-badge { font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--border); padding: 2px 8px; border-radius: 999px; background: var(--surface); }

.tile-icon { display: inline-grid; place-items: center; flex-shrink: 0; width: 48px; height: 48px; border-radius: 15px; color: #fff; }
.tile-icon .ic { width: 24px; height: 24px; }
.c-violet { background: linear-gradient(135deg, #5b3df5, #9a6bff); box-shadow: 0 8px 18px rgba(91, 61, 245, .28); }
.c-blue { background: linear-gradient(135deg, #2563eb, #38bdf8); box-shadow: 0 8px 18px rgba(37, 99, 235, .28); }
.c-teal { background: linear-gradient(135deg, #0a9e8f, #34d3a8); box-shadow: 0 8px 18px rgba(10, 158, 143, .28); }
.c-amber { background: linear-gradient(135deg, #f08a00, #ffc23d); box-shadow: 0 8px 18px rgba(240, 138, 0, .28); }
.c-rose { background: linear-gradient(135deg, #e5366b, #ff7a8a); box-shadow: 0 8px 18px rgba(229, 54, 107, .28); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 200; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; background: #141629; color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 650;
  box-shadow: var(--shadow-lg); transition: all .2s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast .ic { width: 18px; height: 18px; color: #6ee7c8; }

/* ---------------- Buttons & chips ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 14px;
  font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 22px rgba(91, 61, 245, .28); }
.btn-primary:hover { filter: brightness(1.06); border-color: transparent; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { min-height: 38px; padding: 0 12px; border-radius: 11px; font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 650; font-size: 14px; }
.chip .ic { width: 17px; height: 17px; color: var(--primary); }
button.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.active .ic { color: inherit; }
.link-btn { border: 0; background: none; color: var(--primary); font-weight: 650; padding: 6px; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.link-btn .ic { width: 16px; height: 16px; }

/* ---------------- Home ---------------- */
.hero-band { position: relative; overflow-x: clip; overflow-y: visible; isolation: isolate; z-index: 5; }
.hero { position: relative; padding: 56px 0 36px; text-align: center; }
.hero-band .suggest { text-align: start; }
.hero-band::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px 280px at 50% 0%, rgba(124, 92, 255, .22), transparent 70%),
    radial-gradient(500px 260px at 85% 30%, rgba(16, 181, 163, .16), transparent 70%),
    radial-gradient(500px 260px at 15% 40%, rgba(91, 61, 245, .12), transparent 70%);
}
.hero-band::after {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px; -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 65%); mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 65%);
}
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); font-size: 13.5px; font-weight: 650; color: var(--text-2); }
.eyebrow b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--grad); color: #fff; font-size: 12px; }
.hero h1 { margin-top: 18px; font-size: clamp(34px, 7vw, 64px); letter-spacing: -.035em; font-weight: 850; line-height: 1.05; }
.hero h1 .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin: 16px auto 0; max-width: 640px; color: var(--muted); font-size: clamp(16px, 2.2vw, 19px); }
.hero-search { position: relative; max-width: 660px; margin: 30px auto 0; text-align: start; }
.hero-search > .ic { position: absolute; inset-inline-start: 22px; top: 32px; transform: translateY(-50%); color: var(--muted); width: 24px; height: 24px; pointer-events: none; }
.hero-search input {
  width: 100%; height: 64px; padding-inline: 58px 20px; font-size: 18px; border-radius: 18px; outline: none;
  border: 1.5px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
}
.hero-search input:focus { border-color: var(--primary); box-shadow: var(--ring), var(--shadow); }
.suggest { position: absolute; left: 0; right: 0; top: 72px; z-index: 30; padding: 8px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; color: var(--text-2); font-size: 14px; font-weight: 600; }
.badges span { display: inline-flex; align-items: center; gap: 7px; }
.badges .ic { width: 18px; height: 18px; color: var(--accent); }

.section { padding: 26px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-head h2 { font-size: clamp(20px, 3vw, 26px); font-weight: 800; }
.section-head p { color: var(--muted); margin-top: 4px; font-size: 15px; }
.section-head .muted { font-size: 14px; font-weight: 600; white-space: nowrap; }

.pop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.pop-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; min-height: 196px; padding: 22px;
  border-radius: var(--radius-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.pop-card::after { content: ""; position: absolute; inset: auto -60px -80px auto; width: 200px; height: 200px; border-radius: 50%; background: var(--grad-soft); }
[dir="rtl"] .pop-card::after { inset: auto auto -80px -60px; }
.pop-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); text-decoration: none; }
.pop-card h3 { font-size: 19px; font-weight: 800; }
.pop-card p { color: var(--muted); font-size: 14.5px; }
.pop-card .go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--primary); font-size: 14.5px; position: relative; z-index: 1; }
.pop-card .go .ic { width: 18px; height: 18px; }
.pop-card .num-badge { position: absolute; top: 18px; inset-inline-end: 18px; }
.pop-card .tags { display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.pop-card .tags span { font-size: 12.5px; font-weight: 650; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }

.recent-row { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.recent-row::-webkit-scrollbar { display: none; }
.recent-item { flex-shrink: 0; display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px 10px 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }
.recent-item:hover { border-color: var(--border-strong); text-decoration: none; }
.recent-item .tile-icon { width: 36px; height: 36px; border-radius: 11px; box-shadow: none; }
.recent-item .tile-icon .ic { width: 19px; height: 19px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cat-tile { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); text-align: start; box-shadow: var(--shadow-sm); }
.cat-tile:hover, .cat-tile.active { border-color: var(--primary); text-decoration: none; }
.cat-tile.active { background: var(--primary-soft); }
.cat-tile b { display: block; font-size: 16px; }
.cat-tile small { color: var(--muted); font-size: 13.5px; font-weight: 600; }

.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.calc-card { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .15s ease, transform .15s ease; }
.calc-card:hover { border-color: var(--primary); transform: translateY(-1px); text-decoration: none; }
.calc-card h3 { font-size: 16px; font-weight: 750; margin-bottom: 2px; }
.calc-card p { font-size: 14px; color: var(--muted); }
.calc-card .num-badge { position: absolute; top: 14px; inset-inline-end: 14px; }
.calc-card .card-text { padding-inline-end: 48px; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); grid-column: 1 / -1; }

.why-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.why-card { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.why-card .why-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.why-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 6px; }
.why-card p { color: var(--muted); font-size: 14.5px; }


/* ---------------- Article pages (About / Privacy) ---------------- */
.article { max-width: 760px; margin: 0 auto; padding: 36px 0 20px; }
.article h1 { font-size: clamp(30px, 5vw, 44px); font-weight: 850; letter-spacing: -.03em; }
.article .lead { margin-top: 12px; font-size: 18px; color: var(--muted); }
.article h2 { margin: 30px 0 10px; font-size: 21px; font-weight: 800; }
.article p, .article li { color: var(--text-2); font-size: 16.5px; }
.article p + p { margin-top: 12px; }
.article ul { padding-inline-start: 22px; margin: 8px 0 0; }
.article li + li { margin-top: 6px; }

/* ---------------- Calculator page ---------------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); padding-top: 22px; }
.crumbs a { color: var(--muted); }
.crumbs svg, .crumbs .ic { width: 14px; height: 14px; }
.calc-head { display: flex; gap: 16px; align-items: center; padding: 14px 0 22px; }
.calc-head > div { min-width: 0; }
.calc-head h1 { overflow-wrap: anywhere; hyphens: auto; }
.calc-head .tile-icon { width: 64px; height: 64px; border-radius: 20px; }
.calc-head .tile-icon .ic { width: 32px; height: 32px; }
.calc-head h1 { font-size: clamp(28px, 4.8vw, 42px); letter-spacing: -.03em; font-weight: 850; }
.calc-head p { color: var(--muted); margin-top: 6px; font-size: 16px; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.calc-layout > *, .page-bottom > * { min-width: 0; }
@media (min-width: 920px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; }
  .result-col { position: sticky; top: calc(var(--header-h) + 16px); }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); padding: 22px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 17px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title .ic { width: 20px; height: 20px; color: var(--primary); }
.panel-title > span:first-child { display: inline-flex; align-items: center; gap: 8px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; margin: -4px -4px 16px; max-width: calc(100% + 8px); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex-shrink: 0; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 650; font-size: 14.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.tab .ic { width: 17px; height: 17px; }
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.seg button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; font-weight: 650; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.full { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.seg.full button { padding: 6px 8px; min-height: 52px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.seg-sub { font-size: 12px; font-weight: 600; opacity: .75; white-space: nowrap; }

.mode-question { font-size: 15px; color: var(--muted); margin-bottom: 14px; }
.fields { display: grid; gap: 16px; }
.fields.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 380px) { .fields.two { grid-template-columns: 1fr; } }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fields > .field.wide { grid-column: 1 / -1; }
.field-group { grid-column: 1 / -1; font-weight: 700; margin: 4px 0 -8px; }
.fields.three .input-box input { padding-inline: 12px; }
.field label, .field .label { display: block; font-weight: 700; font-size: 14.5px; margin-bottom: 7px; color: var(--text-2); }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.input-box { position: relative; display: flex; align-items: center; }
.input-box input, .input-box select {
  width: 100%; height: 60px; padding-inline: 18px 56px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.input-box select { padding-inline: 14px 36px; font-size: 18px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 27px, calc(100% - 14px) 27px; background-size: 6px 6px; background-repeat: no-repeat; }
[dir="rtl"] .input-box select { background-position: 20px 27px, 14px 27px; }
.input-box input::placeholder { color: var(--muted); opacity: .5; font-weight: 500; }
.input-box input:focus, .input-box select:focus { border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); }
.input-box input[aria-invalid="true"], .input-box select[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(224, 54, 79, .12); }
.input-box .unit { position: absolute; inset-inline-end: 16px; color: var(--muted); font-weight: 700; pointer-events: none; }
.field-error { color: var(--danger); font-size: 13.5px; margin-top: 7px; font-weight: 600; }
.field-error:empty { display: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 650; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

/* Date of birth: day / month / year boxes */
.date3 { display: grid; gap: 8px; grid-template-columns: minmax(0, .9fr) minmax(0, 1.6fr) minmax(0, 1.2fr); }
.date3 .input-box input { padding-inline: 14px; text-align: center; }
.date3 .input-box select { font-weight: 700; }
.date-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.date-row > .date3 { flex: 1 1 260px; min-width: 0; }
.date-row .btn { min-height: 60px; flex: 0 0 auto; }
.date-row .btn[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.time2 { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }

/* Result */
.result-hero {
  position: relative; overflow: hidden; border-radius: var(--radius-xl); padding: 24px; color: #fff; min-height: 156px;
  background: var(--grad); box-shadow: 0 22px 44px rgba(91, 61, 245, .28);
}
.result-hero::before { content: ""; position: absolute; inset: auto -50px -90px auto; width: 240px; height: 240px; border-radius: 50%; background: rgba(255, 255, 255, .10); }
.result-hero::after { content: ""; position: absolute; inset: -80px auto auto -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .06); }
[dir="rtl"] .result-hero::before { inset: auto auto -90px -50px; }
.result-hero > * { position: relative; z-index: 1; }
.result-hero.is-empty { background: var(--surface); color: var(--muted); box-shadow: none; border: 1.5px dashed var(--border-strong); }
.result-hero.is-empty::before, .result-hero.is-empty::after { display: none; }
.result-label { font-size: 14px; font-weight: 700; opacity: .92; letter-spacing: .01em; }
.result-big { font-size: clamp(36px, 8vw, 56px); font-weight: 850; letter-spacing: -.03em; line-height: 1.08; margin-top: 6px; word-break: break-word; font-variant-numeric: tabular-nums; }
.result-sub { margin-top: 8px; font-size: 16px; opacity: .95; }
.result-hero.is-empty .result-big { font-size: 20px; font-weight: 650; letter-spacing: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 14px; background: rgba(255, 255, 255, .2); margin-top: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stat { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 650; }
.stat-value { font-size: 20px; font-weight: 800; margin-top: 3px; word-break: break-word; font-variant-numeric: tabular-nums; }
.stat.wide { grid-column: 1 / -1; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 11px 0 11px 42px; border-bottom: 1px dashed var(--border); font-family: var(--mono); font-size: 15px; direction: ltr; text-align: left; overflow-wrap: anywhere; }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 10px; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-family: var(--font); font-size: 13px; }
.steps .formula-note { font-family: var(--font); color: var(--muted); font-size: 13.5px; display: block; }
[dir="rtl"] .steps .formula-note { direction: rtl; text-align: right; }

.history-list { list-style: none; margin: 0; padding: 0; }
.history-list button { display: block; width: 100%; text-align: start; padding: 11px 12px; border: 0; border-radius: 12px; background: transparent; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--text-2); }
.history-list button:hover { background: var(--surface-2); color: var(--text); }
.note { display: flex; gap: 10px; padding: 14px; border-radius: var(--radius-sm); font-size: 14.5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.note .ic { width: 20px; height: 20px; color: var(--primary); margin-top: 1px; }
.note.warn { background: rgba(217, 136, 0, .08); border-color: rgba(217, 136, 0, .3); }

/* Phone: a small result bar stays at the bottom while the form is on screen */
.result-dock {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 35; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 16px; border-radius: 18px; background: var(--grad); color: #fff; box-shadow: var(--shadow-lg);
  transform: translateY(140%); transition: transform .25s ease;
}
.result-dock.show { transform: none; }
.result-dock .dock-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-dock small { font-size: 12px; opacity: .85; font-weight: 650; }
.result-dock strong { font-size: 19px; font-weight: 850; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.result-dock button { border: 0; background: rgba(255, 255, 255, .2); color: #fff; min-height: 40px; padding: 0 14px; border-radius: 12px; font-weight: 700; }
@media (min-width: 920px) { .result-dock { display: none; } }

/* FAQ */
.faq details { border-bottom: 1px solid var(--border); }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; padding: 16px 0; 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: "+"; flex-shrink: 0; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; line-height: 1; color: var(--primary); }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding-bottom: 16px; color: var(--muted); }
.page-bottom { margin: 18px 0 24px; display: grid; gap: 16px; }
@media (min-width: 920px) { .page-bottom { grid-template-columns: 1.4fr 1fr; align-items: start; } }

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 36px 0 calc(28px + env(safe-area-inset-bottom)); margin-top: 32px; font-size: 14.5px; }
.footer-grid { display: grid; gap: 26px; grid-template-columns: 1.4fr 1fr 1fr; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-about { grid-column: 1 / -1; } }
.footer-about p { color: var(--muted); margin-top: 10px; max-width: 360px; }
.site-footer h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li + li { margin-top: 8px; }
.site-footer a { color: var(--text-2); }
.footer-bottom { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; color: var(--muted); }
.footer-bottom span { display: inline-flex; align-items: center; gap: 6px; }
.footer-bottom .ic { width: 16px; height: 16px; color: var(--accent); }
.lang-links { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lang-links button { border: 0; background: none; padding: 0; color: var(--text-2); }
.lang-links button:hover { color: var(--primary); text-decoration: underline; }

/* ---------------- Print ---------------- */
@media print {
  .site-header, .site-footer, .row-actions, .result-dock, .tabs, .page-bottom, .crumbs, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .panel, .stat { box-shadow: none; border-color: #ccc; }
  .result-hero { color: #000; background: #fff !important; border: 2px solid #000; box-shadow: none; }
  .calc-layout { grid-template-columns: 1fr 1fr; }
  .result-col { position: static; }
}

/* Age: years / months / days */
.age-parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.age-part { display: flex; flex-direction: column; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .16); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.age-num { font-size: clamp(32px, 8vw, 50px); font-weight: 850; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.age-unit { font-size: 14px; font-weight: 700; opacity: .92; }

/* Progress ring (current year of age) */
.progress-card { display: flex; align-items: center; gap: 16px; margin-top: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.ring { width: 76px; height: 76px; flex-shrink: 0; transform: rotate(-90deg); }
[dir="rtl"] .ring { transform: rotate(-90deg) scaleY(-1); }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.ring-fg { fill: none; stroke: url(#none); stroke: var(--primary); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.progress-text { min-width: 0; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-inline-start: 4px; vertical-align: 1px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Lists inside tabs */
.sub-title { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 10px; }
.sub-title:not(:first-child) { margin-top: 22px; }
.ms-list, .future-list, .fam-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ms-list li, .future-list li, .fam-list li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.ms-dot { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.ms-dot .ic { width: 19px; height: 19px; }
.ms.done { opacity: .72; }
.ms.done .ms-dot { background: rgba(15, 159, 110, .12); color: var(--ok); }
.ms-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ms-main b { font-size: 16px; font-variant-numeric: tabular-nums; }
.ms-main .muted { font-size: 13.5px; }
.ms-when { font-size: 13px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.ms.done .ms-when { color: var(--muted); }
.future-list { margin-top: 10px; }
.fy { font-weight: 850; font-size: 18px; min-width: 56px; color: var(--primary); font-variant-numeric: tabular-nums; }
.family-add { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .family-add { grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); } }
.fam-list { margin-top: 16px; }
.fam-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-weight: 800; flex-shrink: 0; }
#time-box summary { list-style: none; }
#time-box summary::-webkit-details-marker { display: none; }
#time-box[open] summary { margin-bottom: 2px; }
.ms-list > li, .future-list > li, .fam-list > li { min-width: 0; flex-wrap: wrap; }
.ms-main { flex: 1 1 150px; }
.ms-when { white-space: normal; text-align: end; flex: 0 1 auto; }
.ms-main b, .ms-main .muted { overflow-wrap: anywhere; }

/* Percentage: charts and table */
.visual:empty { display: none; }
.visual { margin-top: 14px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.vbars { display: grid; gap: 14px; }
.vbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); font-weight: 650; margin-bottom: 6px; }
.vbar-top b { color: var(--text); font-variant-numeric: tabular-nums; }
.vbar-track { height: 14px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.vbar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #9aa3c4, #c3c9df); transition: width .45s cubic-bezier(.2, .8, .2, 1); }
[dir="rtl"] .vbar-fill { margin-inline-start: 0; }
.vbar-fill.up { background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.vbar-fill.down { background: linear-gradient(90deg, #f2672a, #ffa04d); }
.vbar-fill.alt { background: linear-gradient(90deg, var(--accent), #5ee0cf); }
.donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 120px; height: 120px; flex-shrink: 0; }
.donut-bg { fill: none; stroke: var(--surface-3); stroke-width: 14; }
.donut-fg { fill: none; stroke: var(--primary); stroke-width: 14; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dasharray .5s ease; }
.donut-text { font-size: 15px; font-weight: 800; fill: var(--text); font-family: var(--font); }
.donut-legend { display: grid; gap: 8px; font-size: 15px; color: var(--text-2); }
.donut-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-inline-end: 8px; vertical-align: -1px; }
.lg-part { background: var(--primary); }
.lg-rest { background: var(--surface-3); border: 1px solid var(--border-strong); }
.table-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ptable th, .ptable td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); }
.ptable th { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ptable td:first-child { font-weight: 700; color: var(--primary); }
.ptable tbody tr:hover { background: var(--surface-2); }
.hero-clock { margin-top: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-weight: 750; font-size: 17px; font-variant-numeric: tabular-nums; }
.hero-clock .live-dot { background: #7dffb8; margin: 0; }
.hero-clock .sec { min-width: 3.2ch; display: inline-block; }

/* Birth time: hour : minute : AM/PM */
.time3 { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1.1fr); gap: 8px; align-items: center; }
.time-colon { font-size: 24px; font-weight: 800; color: var(--muted); }
.date3 .input-box select, .time3 .input-box select { padding-inline: 10px 22px; font-size: 17px; background-position: calc(100% - 14px) 27px, calc(100% - 9px) 27px; }
[dir="rtl"] .date3 .input-box select, [dir="rtl"] .time3 .input-box select { padding-inline: 10px 22px; background-position: 14px 27px, 9px 27px; }
.input-box select:disabled { opacity: .45; cursor: not-allowed; }
#time-box.is-off .hint { display: none; }
#time-box .check { font-weight: 650; }

/* Installing is impossible inside a frame (preview links) */
.in-frame [data-install], .in-frame [data-install-hint] { display: none !important; }

/* Scientific calculator keypad */
.keypad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.key { min-height: 52px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 18px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.key:active { transform: scale(.97); }
.key.fn { font-size: 15px; background: var(--surface-2); }
.key.op { color: var(--primary); background: var(--primary-soft); border-color: transparent; font-size: 20px; }
.key.ctl { color: #d14343; background: var(--surface-2); }
.key.eq { background: var(--grad); color: #fff; border: 0; font-size: 22px; }
.key:focus-visible { outline: none; box-shadow: var(--ring); }
#f-expr { font-size: 20px; font-family: var(--mono); }
.sci-live { min-height: 30px; margin-top: 6px; font-size: 22px; font-weight: 800; color: var(--primary); text-align: end; overflow-wrap: anywhere; }
.result-big { overflow-wrap: anywhere; }

/* Unit converter */
.swap-btn { grid-column: 1 / -1; justify-self: start; }
.ptable tr.hl td { background: var(--primary-soft); font-weight: 700; }
.ptable td { overflow-wrap: anywhere; }
.stat-value { overflow-wrap: anywhere; }

/* Several-line boxes (lists of names or numbers) */
.input-box.area-box { height: auto; }
.input-box textarea { width: 100%; min-height: 120px; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: 17px; line-height: 1.5; resize: vertical; outline: none; }
.input-box textarea:focus { border-color: var(--primary); background: var(--surface); box-shadow: var(--ring); }
.input-box textarea[aria-invalid="true"] { border-color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip-n { min-width: 46px; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-weight: 800; font-size: 18px; text-align: center; }
.die { width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--surface); border: 2px solid var(--primary); font-size: 22px; font-weight: 800; }
.team-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 14px; }
.team-list .panel { padding: 12px 14px; margin: 0; }
.team-list ol { margin: 6px 0 0 18px; }
.gen-btn { grid-column: 1 / -1; }

/* Meeting planner */
.tz-table td { white-space: nowrap; }
.tz-table td.work { color: var(--text); font-weight: 700; }
.tz-table td.awake { color: var(--text); }
.tz-table td.night { color: var(--muted); opacity: .6; }
.tz-table td small { color: var(--muted); font-weight: 500; }
