/*!
 * DevClean — shared stylesheet
 * Single file, no framework, no build step. Dark theme by default with a
 * light theme available via [data-theme="light"] on <html>.
 */

/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-raised: #1c2129;
  --border: #2b323c;
  --border-strong: #3a424d;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --text-faint: #6e7b8a;
  --accent: #3fb950;
  --accent-hover: #4ac95c;
  --accent-dim: rgba(63, 185, 80, 0.12);
  --danger: #f85149;
  --link: #58a6ff;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 860px;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-raised: #ffffff;
  --border: #d8dee4;
  --text: #1f2328;
  --text-dim: #59636e;
  --text-faint: #818b98;
  --accent: #1a7f37;
  --accent-hover: #16702f;
  --accent-dim: rgba(26, 127, 55, 0.10);
  --danger: #cf222e;
  --link: #0969da;
  --shadow: 0 1px 3px rgba(31, 35, 40, 0.12);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 650; margin: 0 0 0.6em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.25rem); letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; margin-top: 2.2em; }
h3 { font-size: 1.08rem; margin-top: 1.8em; }
p { margin: 0 0 1.1em; }
ul, ol { margin: 0 0 1.1em; padding-left: 1.4em; }
li { margin-bottom: 0.4em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.12em 0.4em;
}
pre {
  font-family: var(--mono);
  font-size: 0.83rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.1rem; }

/* Screen-reader-only helper, used for the ad labels and skip link. */
.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: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
}
.brand {
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #04140a;
  font-size: 0.85rem;
  font-weight: 800;
}
.nav { margin-left: auto; display: flex; align-items: center; gap: 1.15rem; }
.nav a { color: var(--text-dim); font-size: 0.92rem; font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }

/* ------------------------------------------------------------------ main */
main { flex: 1 0 auto; padding: 2.2rem 0 3rem; }
.lede { font-size: 1.06rem; color: var(--text-dim); margin-bottom: 1.6rem; max-width: 62ch; }

.breadcrumb { font-size: 0.85rem; color: var(--text-faint); margin-bottom: 1rem; }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb span { margin: 0 0.4rem; }

/* -------------------------------------------------------------- tool card */
.tool {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-bottom: 1.5rem;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}
.field-label .hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-faint); }

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.6;
  tab-size: 4;
}
textarea:focus, select:focus, input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea[readonly] { background: var(--bg-raised); color: var(--text-dim); }
textarea::placeholder { color: var(--text-faint); }

/* option chips */
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.chip { position: relative; }
.chip input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.chip span {
  display: block;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 0.36rem 0.85rem;
  font-size: 0.855rem;
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, color .12s, background .12s;
}
.chip span:hover { color: var(--text); border-color: var(--text-faint); }
.chip input:checked + span {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* extra settings row (tab size, delimiter, toggles) */
.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1rem;
  font-size: 0.87rem;
  color: var(--text-dim);
}
.settings label { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.settings select, .settings input[type="number"], .settings input[type="text"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.45rem;
  font-family: inherit;
  font-size: 0.87rem;
}
.settings input[type="number"] { width: 4.2rem; }
.settings input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* buttons */
.actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  padding: 0.52rem 1.05rem;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
button:hover { border-color: var(--text-faint); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04140a;
  font-weight: 650;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
html[data-theme="light"] .btn-primary { color: #fff; }
.btn-ghost { background: transparent; }

.status {
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-left: auto;
  text-align: right;
  min-height: 1.2em;
}
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--accent); }

.output-block { margin-top: 1.3rem; }

/* -------------------------------------------------------------- ad slots */
/* Height is reserved up front so that a loading ad cannot push the page
   around (Cumulative Layout Shift is a Core Web Vitals ranking factor). */
.ad-slot {
  margin: 2rem auto;
  text-align: center;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ad-slot > ins { display: block; width: 100%; }
.ad-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 0.35rem;
}
.ad-slot--inline { min-height: 280px; }

/* ------------------------------------------------------------ tool index */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  list-style: none;
}
.tool-grid li { margin: 0; }
.tool-card {
  display: block;
  height: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  color: var(--text);
  transition: border-color .12s, transform .12s;
}
.tool-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tool-card strong { display: block; font-size: 0.98rem; margin-bottom: 0.25rem; font-weight: 620; }
.tool-card span { display: block; font-size: 0.855rem; color: var(--text-dim); line-height: 1.5; }

/* --------------------------------------------------------------- content */
.prose { max-width: 68ch; }
.prose h2 { scroll-margin-top: 80px; }

.faq { margin: 1.2rem 0; }
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  margin-bottom: 0.55rem;
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  padding: 0.75rem 0.95rem;
  font-weight: 570;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--text-faint); font-size: 1.15rem; line-height: 1; }
.faq details[open] summary::after { content: "\2212"; }
.faq details > div { padding: 0 0.95rem 0.85rem; color: var(--text-dim); font-size: 0.94rem; }
.faq details > div p:last-child { margin-bottom: 0; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1rem;
  margin: 1.5rem 0;
  font-size: 0.94rem;
}
.callout p:last-child { margin-bottom: 0; }

.related {
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
  padding-top: 1.4rem;
}
.related ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.related li { margin: 0; }
.related a {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.86rem;
  color: var(--text-dim);
}
.related a:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 0.83rem; text-transform: uppercase; letter-spacing: 0.04em; }

.meta-line { font-size: 0.85rem; color: var(--text-faint); margin-bottom: 1.6rem; }

/* ---------------------------------------------------------------- footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 1.8rem 0;
  font-size: 0.87rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.footer-cols h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
}
.footer-cols ul { list-style: none; padding: 0; margin: 0; }
.footer-cols li { margin-bottom: 0.3rem; }
.footer-cols a { color: var(--text-dim); }
.footer-cols a:hover { color: var(--text); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  align-items: center;
  color: var(--text-faint);
  font-size: 0.83rem;
}
.footer-bottom .spacer { margin-left: auto; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 620px) {
  .nav { gap: 0.85rem; }
  .nav a { font-size: 0.87rem; }
  .nav .nav-hide-sm { display: none; }
  main { padding: 1.6rem 0 2.4rem; }
  .status { margin-left: 0; width: 100%; text-align: left; }
  textarea { min-height: 160px; }
}

@media print {
  .site-header, .site-footer, .ad-slot, .actions, .options { display: none; }
}

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