/* =========================================================================
   toolhub — stylesheet
   Organized: tokens → base → layout → header → homepage → tool page
   → components (panel, fields, buttons, result, breadcrumb, faq, related)
   → AI card → utilities
   ========================================================================= */

/* ---- Design tokens ---- */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa0aa;
  --accent: #4f8cff;
  --accent2: #22c55e;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --brand-grad: linear-gradient(135deg, #4f8cff 0%, #7c5cff 100%);
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1000px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.22);
  --focus: 0 0 0 3px rgba(79, 140, 255, 0.4);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --panel: #fff;
    --panel2: #f1f3f6;
    --border: #e3e6ea;
    --text: #1a1d23;
    --muted: #5f6571;
    --accent-soft: rgba(79, 140, 255, 0.1);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --focus: 0 0 0 3px rgba(79, 140, 255, 0.3);
  }
}

/* ---- Base ---- */
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  line-height: 1.25;
}
img {
  max-width: 100%;
}

/* Visible focus for keyboard users */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

/* ---- Layout ---- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px;
}

/* Skip to content (a11y) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  font-weight: 700;
}
.skip-link:focus {
  left: 0;
}

/* ---- Header ---- */
header.site {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(1.1);
}
.site-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.logo:hover {
  text-decoration: none;
}
.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: block;
  flex: none;
}
.logo .wordmark span {
  color: var(--accent);
}
nav.primary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
nav.primary a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  transition:
    color 0.12s,
    background 0.12s;
}
nav.primary a:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--panel2);
}

/* ---- Homepage ---- */
.hero {
  padding: 56px 18px 26px;
  text-align: center;
}
.hero .badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: 42px;
  margin: 0 0 12px;
  letter-spacing: -0.03em;
}
.hero h1 .accent {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  color: var(--muted);
  margin: 0 auto;
  max-width: 580px;
}
.searchbar {
  max-width: 540px;
  margin: 22px auto 0;
  position: relative;
}
.searchbar::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  border: 2px solid var(--muted);
  border-radius: 999px;
  box-shadow: 6px 6px 0 -2px var(--muted);
  pointer-events: none;
}
.searchbar input {
  width: 100%;
  padding: 14px 18px 14px 46px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  outline: none;
  box-shadow: var(--shadow);
}
.searchbar input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  margin: 36px 0 14px;
}
.section-label::before {
  content: '';
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: var(--brand-grad);
  flex: none;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 6px 0 10px;
}
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition:
    transform 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  display: block;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--brand-grad);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}
.card:hover::before {
  transform: scaleX(1);
}
.card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--text);
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  flex: none;
}

/* ---- Tool page ---- */
.tool-main {
  padding: 14px 0 40px;
}
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  padding: 14px 0 0;
}
.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.breadcrumb li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb li + li::before {
  content: '›';
  color: var(--muted);
  opacity: 0.6;
}
.breadcrumb a {
  color: var(--muted);
}
.breadcrumb a:hover {
  color: var(--text);
}
.breadcrumb [aria-current] {
  color: var(--text);
  font-weight: 600;
}

.tool-head {
  margin: 10px 0 18px;
}
.tool-head h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.tool-head p {
  color: var(--muted);
  margin: 0;
}

/* ---- Panel & form controls ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel-title {
  margin: 0 0 14px;
  font-size: 16px;
}
.panel-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}
.field .hint {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row .field {
  flex: 1;
  min-width: 130px;
  margin-bottom: 14px;
}

/* checkbox group */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}
.check-group label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
}
.check-group input {
  width: auto;
}

/* range slider */
.range-field input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
  padding: 0;
  background: transparent;
  border: none;
}
.range-val {
  font-weight: 700;
  color: var(--accent);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand-grad);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition:
    filter 0.1s,
    box-shadow 0.14s,
    transform 0.06s;
  font-family: inherit;
  box-shadow: 0 2px 10px rgba(79, 140, 255, 0.25);
}
.btn:hover {
  filter: brightness(1.08);
  box-shadow: 0 4px 16px rgba(79, 140, 255, 0.35);
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ---- Result ---- */
.result {
  margin-top: 18px;
  padding: 18px;
  background: var(--panel2);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 18px;
  min-height: 24px;
}
.result.is-error {
  border-color: var(--danger);
  border-style: solid;
}
.result .big {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent2);
  word-break: break-word;
}
.result .big.is-warn {
  color: var(--warn);
}
.result .big.is-danger {
  color: var(--danger);
}
.result .big.is-neutral {
  color: var(--text);
}
.result .sub {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}
.result code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  word-break: break-all;
}
.code-out {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 10px;
  padding: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 320px;
}
.palette-group {
  margin-top: 12px;
}
.palette-group h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}
.palette .sw {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
}
.palette .sw .chip {
  height: 44px;
}
.palette .sw .lbl {
  font-size: 11px;
  padding: 4px 6px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
/* ---- AI banner (home) + agents page ---- */
.ai-banner {
  margin: 22px 0;
  background: linear-gradient(135deg, var(--panel), var(--panel2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.ai-banner::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brand-grad);
}
.ai-banner-inner h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.ai-banner p {
  color: var(--muted);
  margin: 0 0 14px;
  max-width: 70ch;
}
.agents-content pre.code-out {
  margin-top: 8px;
}

/* stat grid (word counter etc.) */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.stat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.stat .v {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.stat .l {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ---- Content sections ---- */
.content {
  padding: 22px 0;
}
.content h2 {
  font-size: 22px;
  margin: 26px 0 10px;
}
.content h2:first-child {
  margin-top: 0;
}
.content p,
.content li {
  color: var(--muted);
}
.content ul,
.content ol {
  padding-left: 20px;
}
.content li {
  margin: 4px 0;
}

/* FAQ */
.faq {
  padding: 8px 0 30px;
}
.faq h2 {
  font-size: 22px;
  margin: 26px 0 12px;
}
.faq details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  margin-bottom: 10px;
  overflow: hidden;
}
.faq summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::after {
  content: '+';
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s;
}
.faq details[open] summary::after {
  content: '–';
}
.faq summary:hover {
  color: var(--accent);
}
.faq .answer {
  padding: 0 16px 14px;
  color: var(--muted);
}

/* Related tools */
.related {
  padding: 8px 0 30px;
}
.related h2 {
  font-size: 20px;
  margin: 22px 0 12px;
}

/* ---- Footer ---- */
footer.site {
  border-top: 1px solid var(--border);
  background: var(--panel);
  margin-top: 40px;
  padding: 32px 0 20px;
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.footer-brand .logo {
  font-size: 18px;
}
.footer-brand .logo-mark {
  width: 26px;
  height: 26px;
}
.footer-tag {
  color: var(--muted);
  font-size: 14px;
  margin: 12px 0 0;
  max-width: 44ch;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
}
.footer-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 2px;
}
.footer-links a:hover {
  color: var(--text);
}
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: space-between;
  padding-top: 16px;
  color: var(--muted);
  font-size: 13px;
}
footer.site a {
  color: var(--muted);
}
footer.site a:hover {
  color: var(--text);
}

/* ---- AI accessibility card (collapsible) ---- */
.ai-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin: 10px 0 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ai-card > summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.ai-card > summary::-webkit-details-marker {
  display: none;
}
.ai-card > summary::after {
  content: '+';
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.15s;
}
.ai-card[open] > summary::after {
  content: '\2013';
}
.ai-card > summary:hover {
  color: var(--accent);
}
.ai-card > p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 18px 12px;
}
.ai-card .btn-row {
  margin: 0 18px 12px;
}
.ai-card .ai-out {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 0 18px 14px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
}
.ai-card script {
  display: none;
}

/* ---- Support CTA ---- */
.support-cta {
  text-align: center;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 22px 0;
}
.support-cta h3 {
  margin: 0 0 6px;
}
.support-cta p {
  color: var(--muted);
  margin: 0 0 14px;
}

/* ---- Utilities ---- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.text-center {
  text-align: center;
}

/* Recently used tools */
.recent-tools {
  margin: 8px 0 20px;
}
.recent-tools h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
}
.recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.recent-list a {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.12s;
}
.recent-list a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* Color swatch */
.swatch {
  margin-top: 12px;
  height: 60px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
