:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f3fa;
  --fg: #161a2b;
  --muted: #5a6078;
  --border: #d9deec;
  --accent: #4f46e5;
  --accent-2: #0ea5e9;
  --accent-fg: #ffffff;
  --accent-soft: #e8e7ff;
  --focus: #f59e0b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1020;
    --surface: #161b2e;
    --surface-2: #1d2439;
    --fg: #eef0f8;
    --muted: #a7aec6;
    --border: #2b3350;
    --accent: #8b87ff;
    --accent-2: #38bdf8;
    --accent-fg: #0d1020;
    --accent-soft: #272d55;
    --focus: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.1rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  background: var(--surface);
  color: var(--fg);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  z-index: 10;
}

.skip-link:focus { left: 0.75rem; }

/* ---------- header ---------- */

.site-header {
  background: linear-gradient(135deg, #4338ca 0%, var(--accent) 45%, #0284c7 100%);
  color: #ffffff;
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #ffffff;
  font-weight: 750;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand svg { width: 30px; height: 30px; }

.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: inline-block;
  color: #ffffff;
  text-decoration: none;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.2);
}

.site-header :focus-visible { outline-color: #ffffff; }

/* ---------- page heading ---------- */

.page-head { padding: 2.1rem 0 0.4rem; }

.eyebrow {
  display: inline-block;
  margin: 0 0 0.6rem;
  padding: 0.22rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

h2 {
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  margin: 2.2rem 0 0.7rem;
}

h3 {
  font-size: 1.02rem;
  margin: 1.2rem 0 0.25rem;
}

.lead {
  color: var(--muted);
  font-size: 1.08rem;
  margin: 0;
  max-width: 62ch;
}

.crumbs ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0;
  margin: 1.1rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.crumbs li + li::before { content: "/"; margin-right: 0.3rem; }

.crumbs a { color: var(--muted); }

/* ---------- tool card ---------- */

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 1.1rem 0 0;
}

.fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.2rem;
  align-items: flex-end;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.field > label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 42px;
}

.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

input[type="text"],
input[type="number"],
select {
  font: inherit;
  min-height: 42px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  min-width: 0;
}

input[type="text"] { min-width: 14rem; }

input[type="color"] {
  width: 64px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
}

input[type="range"] { accent-color: var(--accent); width: 170px; }

#rate-value { font-weight: 600; color: var(--accent); }

.io-label {
  display: block;
  font-weight: 650;
  font-size: 0.95rem;
  margin: 0.2rem 0 0.45rem;
}

textarea {
  display: block;
  width: 100%;
  min-height: 170px;
  font: 15.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--fg);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea[dir="rtl"] {
  text-align: right;
  font-family: system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 17px;
}

.preview {
  margin-top: 0.2rem;
  padding: 1rem 1.2rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  min-height: 90px;
  overflow-wrap: anywhere;
}

.preview:empty::before {
  content: "Your formatted preview appears here.";
  color: var(--muted);
}

.preview pre,
.prose pre {
  background: var(--surface-2);
  padding: 0.75rem;
  border-radius: 10px;
  overflow-x: auto;
}

.counts {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.4rem;
}

button {
  font: inherit;
  font-weight: 550;
  min-height: 42px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

button:hover { background: var(--surface-2); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

button.primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

.status {
  min-height: 1.4em;
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0.6rem 0 0;
}

/* ---------- content sections ---------- */

.prose { margin-top: 1.6rem; max-width: 74ch; }

.prose ol,
.prose ul { padding-left: 1.3rem; }

.prose li { margin-bottom: 0.3rem; }

.prose p { margin: 0 0 0.9rem; }

table.examples {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.6rem 0 0.4rem;
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

table.examples th,
table.examples td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

table.examples thead th {
  background: var(--surface-2);
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.examples tbody tr:last-child td { border-bottom: 0; }

table.examples pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 0.05em 0.35em;
  border-radius: 6px;
}

.faq details {
  border-top: 1px solid var(--border);
  padding: 0.8rem 0;
}

.faq details:last-child { border-bottom: 1px solid var(--border); }

.faq summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: "+";
  float: right;
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
}

.faq details[open] summary::after { content: "\2013"; }

.faq details p { margin: 0.5rem 0 0.2rem; color: var(--muted); }

/* ---------- cards ---------- */

.tool-grid {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
}

.tool-grid a {
  display: block;
  height: 100%;
  padding: 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--fg);
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}

.tool-grid a:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.tool-grid strong { display: block; margin-bottom: 0.25rem; }

.tool-grid span { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.group { margin-top: 2.4rem; }

.group h2 { margin: 0; font-size: 1.2rem; }

.group > p { color: var(--muted); margin: 0.3rem 0 0; }

.related-section { margin-top: 2.6rem; }

.related-section h2 { margin-top: 0; }

/* ---------- prose pages ---------- */

.article { max-width: 70ch; }

.article p { margin: 0 0 0.9rem; }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 3.5rem;
  padding: 2rem 0 2.4rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer .cols {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 3rem;
  margin-bottom: 1.4rem;
}

.site-footer h2 {
  font-size: 0.78rem;
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg);
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}

.site-footer a { color: var(--muted); text-decoration: none; }

.site-footer a:hover { color: var(--accent); text-decoration: underline; }

.site-footer .fine { margin: 0; }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .tool-card { padding: 0.95rem; }
  input[type="text"] { min-width: 0; width: 100%; }
  .field { width: 100%; }
  .toolbar button { flex: 1 1 auto; }
  table.examples thead { display: none; }
  table.examples tr,
  table.examples td { display: block; width: 100%; }
  table.examples td { border-bottom: 0; padding: 0.35rem 0.8rem; }
  table.examples tr { border-bottom: 1px solid var(--border); padding: 0.4rem 0; }
}

/* =====================================================================
   Professional polish layer
   ===================================================================== */

:root {
  --shadow-lg: 0 1px 2px rgba(16, 24, 40, 0.05), 0 18px 40px -18px rgba(37, 33, 110, 0.28);
  --ring: 0 0 0 4px var(--accent-soft);
}

@media (prefers-color-scheme: dark) {
  :root { --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -18px rgba(0, 0, 0, 0.7); }
}

body {
  letter-spacing: -0.003em;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: 1080px; }

.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;
}

/* Sticky, slightly translucent header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(120deg, #3b32b8 0%, var(--accent) 45%, #0369a1 100%);
  box-shadow: 0 10px 30px -16px rgba(55, 48, 163, 0.55);
}

.site-header .bar { padding-top: 0.7rem; padding-bottom: 0.7rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand svg { width: 32px; height: 32px; flex: 0 0 auto; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.12)); }

.site-nav a {
  font-size: 0.94rem;
  padding: 0.45rem 0.9rem;
  transition: background 0.15s;
}

.site-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Page heading with a soft backdrop */
.page-head {
  position: relative;
  padding: 2.6rem 0 1.2rem;
  animation: rise 0.55s ease both;
}

.page-head { overflow: hidden; }

.page-head::before {
  content: "";
  position: absolute;
  inset: -1.5rem -1.1rem 0;
  z-index: -1;
  background: radial-gradient(60% 90% at 50% 0%, var(--accent-soft) 0%, transparent 70%);
  opacity: 0.85;
  pointer-events: none;
}

.page-head h1 {
  font-size: clamp(1.9rem, 4.4vw, 2.75rem);
  font-weight: 760;
  letter-spacing: -0.03em;
}

.lead { font-size: 1.12rem; color: var(--muted); max-width: 60ch; }

.eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.09em;
  padding: 0.28rem 0.8rem;
}

.crumbs ol { margin-top: 1.4rem; }

/* Tool card with an accent line and lift */
.tool-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 1.6rem 1.5rem 1.3rem;
  animation: rise 0.6s 0.05s ease both;
}

.tool-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.fields { padding-bottom: 1.15rem; margin-bottom: 1.15rem; }

.field > label { letter-spacing: 0.01em; }

.io-label { font-size: 0.9rem; letter-spacing: 0.01em; color: var(--fg); }

textarea {
  border-radius: 14px;
  min-height: 180px;
  font-size: 15px;
}

textarea:focus { box-shadow: var(--ring); }

.counts { font-size: 0.84rem; letter-spacing: 0.01em; }

.toolbar { gap: 0.55rem; margin-top: 1.1rem; }

button {
  font-size: 0.93rem;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04);
}

button.primary {
  padding-left: 1.4rem;
  padding-right: 1.4rem;
}

/* Status shows as a small pill when there is a message */
.status { min-height: 0; margin: 0.7rem 0 0; }

.status:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
  font-size: 0.88rem;
  animation: rise 0.25s ease both;
}

.status:not(:empty)::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  flex: 0 0 auto;
}

/* Prose sections */
.prose { margin-top: 2.4rem; }

.prose h2 {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  margin-top: 2.6rem;
}

.prose h2::before {
  content: "";
  width: 4px;
  height: 1.1em;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  flex: 0 0 auto;
}

.prose ol > li::marker,
.prose ul > li::marker { color: var(--accent); }

table.examples {
  border-radius: 14px;
  box-shadow: var(--shadow);
}

table.examples tbody tr:nth-child(even) td { background: var(--surface-2); }

table.examples td pre {
  background: transparent;
  padding: 0;
}

.faq details { padding: 0.95rem 0; }

.faq summary { font-size: 1.02rem; }

.faq details[open] p { animation: rise 0.25s ease both; }

/* Feature trust row on the home page */
.features {
  margin-top: 3rem;
}

.features h2 {
  margin: 0 0 1rem;
  font-size: 1.3rem;
  text-align: left;
}

.features ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

.feature {
  padding: 1.2rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.feature h3 { margin: 0 0 0.35rem; font-size: 1rem; }

.feature p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }

/* Hub search and cards */
.search-row { margin-top: 1.3rem; }

#tool-search {
  width: 100%;
  max-width: 520px;
  min-height: 48px;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

#tool-search:focus { outline: none; box-shadow: var(--ring); border-color: var(--accent); }

.group h2 { display: flex; align-items: baseline; gap: 0.6rem; font-size: 1.25rem; }

.group h2 .count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
}

.tool-item[hidden],
.group[hidden],
#no-results[hidden] { display: none; }

.tool-grid a { padding: 1.1rem 1.15rem; }

.tool-grid a::after {
  content: "\2192";
  float: right;
  color: var(--accent);
  font-weight: 600;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s, transform 0.15s;
}

.tool-grid a:hover::after { opacity: 1; transform: translateX(0); }

.empty { color: var(--muted); margin-top: 1.5rem; }

.related-section h2 { font-size: 1.2rem; }

/* Footer, four columns */
.site-footer {
  margin-top: 4rem;
  padding: 3rem 0 1.6rem;
  background: var(--surface);
}

.foot-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 2rem;
}

.foot-brand p { margin: 0.9rem 0 0.4rem; max-width: 34ch; line-height: 1.6; }

.site-footer .brand { color: var(--fg); }

.site-footer .brand svg { filter: none; }

.site-footer .brand span { color: var(--fg); }

.site-footer h2 { font-size: 0.74rem; margin-bottom: 0.8rem; }

.site-footer ul { gap: 0.45rem; }

.foot-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 2.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.foot-bottom p { margin: 0; }

@media (max-width: 860px) {
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .foot-grid { grid-template-columns: 1fr; }
  .site-header .bar { gap: 0.4rem 0.8rem; }
  .site-nav ul { gap: 0; }
  .site-nav a { padding: 0.35rem 0.55rem; font-size: 0.88rem; }
  .page-head { padding-top: 1.7rem; }
  .tool-card { padding: 1.2rem 1rem 1rem; }
}

/* Gentle entrance animation, switched off for people who prefer less motion */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

.site-footer .brand svg rect { stroke: var(--border); stroke-width: 1; }

/* Footer as a fixed dark band, so it looks the same in light and dark mode */
.site-footer {
  --f-bg: #0f1224;
  --f-text: #aab1cc;
  --f-head: #ffffff;
  --f-link: #c7cde3;
  --f-line: rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, #0f1224 0%, #0b0e1d 100%);
  color: var(--f-text);
  border-top: 0;
  padding: 3.4rem 0 1.8rem;
}

.site-footer h2 {
  color: var(--f-head);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.site-footer a { color: var(--f-link); }

.site-footer a:hover { color: #ffffff; text-decoration: none; }

.site-footer ul { gap: 0.55rem; }

.site-footer .brand { color: #ffffff; }

.site-footer .brand span { color: #ffffff; }

.site-footer .brand svg rect { stroke: none; }

.site-footer .foot-brand p { color: var(--f-text); }

.site-footer .foot-brand a { color: #ffffff; font-weight: 550; }

.foot-bottom {
  border-top: 1px solid var(--f-line);
  color: #7f87a6;
}

.foot-bottom p:first-child { color: #c7cde3; }
