/* Cirelay Tools — one stylesheet shared by every subdomain. */
:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f0eb;
  --ink: #1b1d1f;
  --ink-2: #4b5157;
  --ink-3: #737a80;
  --line: #e2e2dc;
  --line-strong: #c9c9c1;
  --accent: #2459d6;
  --accent-ink: #ffffff;
  --accent-soft: #e7eefc;
  --ok: #17803d;
  --warn: #a35a00;
  --bad: #c0362c;
  --c-convert: #2459d6;
  --c-calculate: #0f7d6b;
  --c-developer: #6d3fc0;
  --c-everyday: #c2541b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 22, 25, .05), 0 6px 24px rgba(20, 22, 25, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111315; --surface: #191c1f; --surface-2: #22262a; --ink: #eceeef; --ink-2: #b4bac0; --ink-3: #8a9198;
    --line: #2c3136; --line-strong: #3d444a; --accent: #7aa2ff; --accent-ink: #0d1424; --accent-soft: #1d2a47;
    --ok: #4fc47a; --warn: #f0a44b; --bad: #ff7b6e;
    --c-convert: #7aa2ff; --c-calculate: #3cc7ad; --c-developer: #b18cff; --c-everyday: #ff9a5c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111315; --surface: #191c1f; --surface-2: #22262a; --ink: #eceeef; --ink-2: #b4bac0; --ink-3: #8a9198;
  --line: #2c3136; --line-strong: #3d444a; --accent: #7aa2ff; --accent-ink: #0d1424; --accent-soft: #1d2a47;
  --ok: #4fc47a; --warn: #f0a44b; --bad: #ff7b6e;
  --c-convert: #7aa2ff; --c-calculate: #3cc7ad; --c-developer: #b18cff; --c-everyday: #ff9a5c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; margin-top: 1.8em; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
code, kbd, pre, textarea.mono, .mono { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 20; }
.skip:focus { left: 8px; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.narrow { width: min(800px, 100% - 32px); margin-inline: auto; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 800; }
.brand small { font-weight: 500; color: var(--ink-3); }
.header-spacer { flex: 1; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 10px); width: min(680px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; max-height: calc(100vh - 90px); overflow: auto; }
.menu-panel h3 { grid-column: 1 / -1; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 10px 0 2px; }
.menu-panel h3:first-child { margin-top: 0; }
.menu-panel .menu-all { grid-column: 1 / -1; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
@media (max-width: 560px) { .menu-panel { grid-template-columns: 1fr; position: fixed; left: 16px; right: 16px; width: auto; top: 66px; } }
.menu-link { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: .95rem; }
.menu-link:hover, .menu-link[aria-current="page"] { background: var(--surface-2); }

/* Element tile — every tool has a two-letter mark like a periodic table cell */
.tile { --c: var(--accent); flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); font-weight: 800; font-size: 13px; letter-spacing: -.02em; }
.tile.lg { width: 52px; height: 52px; border-radius: 12px; font-size: 19px; }
.cat-convert { --c: var(--c-convert); }
.cat-calculate { --c: var(--c-calculate); }
.cat-developer { --c: var(--c-developer); }
.cat-everyday { --c: var(--c-everyday); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 40px; padding: 0; }

label { font-weight: 600; font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field .hint { font-weight: 400; color: var(--ink-3); font-size: .82rem; }
input[type="text"], input[type="number"], input[type="search"], input[type="url"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="password"], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem;
}
textarea { min-height: 160px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.swap-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: end; }
@media (max-width: 560px) { .swap-row { grid-template-columns: 1fr; } .swap-row .swap { justify-self: center; transform: rotate(90deg); } }

/* Page */
main { padding: 28px 0 56px; }
.crumbs { font-size: .85rem; color: var(--ink-3); margin-bottom: 14px; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line-strong); }
.page-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.page-head .lede { color: var(--ink-2); font-size: 1.08rem; margin: 0; max-width: 64ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(16px, 3vw, 26px); }
.tool { display: flex; flex-direction: column; gap: 16px; }
.tool .out { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.big-result { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.15; word-break: break-word; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.privacy-note { display: flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--ink-3); }
.privacy-note::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }

.drop { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 30px 18px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { display: block; font-size: 1.1rem; margin-bottom: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.stat .v { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; word-break: break-word; }

table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table-scroll table th, .table-scroll table td { white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.chips a, .chip { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .88rem; }
.chips a:hover { border-color: var(--accent); color: var(--accent); }
.chips a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
button.chip { cursor: pointer; font: inherit; font-size: .88rem; }
button.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.prose { color: var(--ink-2); }
.prose h2, .prose h3 { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li { margin-bottom: .35em; }
section.block { margin-top: 40px; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.faq details p { margin: 8px 0 0; }

.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.tool-card strong { display: block; }
.tool-card span.d { display: block; color: var(--ink-3); font-size: .87rem; line-height: 1.45; }
.tool-card .host { display: block; font-size: .76rem; color: var(--ink-3); font-family: var(--mono); margin-top: 4px; }

.network { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.network a { display: block; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); color: var(--ink); text-decoration: none; }
.network a:hover { background: var(--accent-soft); }
.network strong { display: block; }
.network span { color: var(--ink-3); font-size: .87rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 40px 0 28px; font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 24px; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } .footer-grid .about { grid-column: 1 / -1; } }
.site-footer h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.footer-base { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--ink-3); }

/* Hub */
.hero { padding: 34px 0 10px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.3rem); max-width: 18ch; }
.hero p { font-size: 1.15rem; color: var(--ink-2); max-width: 60ch; }
.search { max-width: 520px; margin-top: 18px; }
.periodic { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.element { --c: var(--accent); position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px; min-height: 132px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.element:hover { border-color: var(--c); transform: translateY(-2px); box-shadow: var(--shadow); }
.element .n { position: absolute; top: 10px; right: 12px; font-size: .75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.element .sym { font-size: 1.9rem; font-weight: 800; color: var(--c); letter-spacing: -.03em; line-height: 1.1; }
.element strong { font-size: .98rem; }
.element span.d { font-size: .82rem; color: var(--ink-3); line-height: 1.4; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 16px; font-size: .88rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { .site-header, .site-footer, .related, .no-print { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* Category colours last so they win over component defaults (.element, .tile). */
.element.cat-convert, .tile.cat-convert, .legend .cat-convert { --c: var(--c-convert); }
.element.cat-calculate, .tile.cat-calculate, .legend .cat-calculate { --c: var(--c-calculate); }
.element.cat-developer, .tile.cat-developer, .legend .cat-developer { --c: var(--c-developer); }
.element.cat-everyday, .tile.cat-everyday, .legend .cat-everyday { --c: var(--c-everyday); }
@media (max-width: 560px) { .page-head .tile.lg { display: none; } }
@media (max-width: 560px) { .periodic { grid-template-columns: repeat(2, minmax(0, 1fr)); } .element { min-height: 0; } .element span.d { display: none; } }
