/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --brand: #1a5ce6;
  --brand-600: #1449bb;
  --brand-50: #eef3fe;
  --hero-from: #1a5ce6;
  --hero-to: #3b2fd1;
  --bg: #ffffff;
  --bg-alt: #f5f7fb;
  --surface: #ffffff;
  --text: #1a2233;
  --text-muted: #5b6477;
  --border: #e2e7f0;
  --success: #12805c;
  --danger: #c62d3b;
  --danger-bg: #fdecee;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -12px rgb(16 32 80 / 0.25);
  --container: 1120px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5b8cff;
    --brand-600: #7aa2ff;
    --brand-50: #17223b;
    --hero-from: #16244a;
    --hero-to: #221a52;
    --bg: #0d1320;
    --bg-alt: #121a2b;
    --surface: #172136;
    --text: #e6eaf3;
    --text-muted: #a0a9bd;
    --border: #263250;
    --success: #3ccf91;
    --danger: #ff7a86;
    --danger-bg: #3a1a22;
    --shadow: 0 10px 30px -12px rgb(0 0 0 / 0.6);
  }
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-600); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
code, kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .1em .4em;
  word-break: break-word;
}
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 800px; }
.center { text-align: center; }
.muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute !important; 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: 16px; top: -48px; z-index: 100;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 0; border-radius: var(--radius-sm);
  padding: .7em 1.2em;
  font: inherit; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }
.btn-ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-lg { padding: .9em 1.6em; font-size: 1.05rem; }
.btn svg { width: 1.1em; height: 1.1em; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; }
.brand {
  display: inline-flex; align-items: center; gap: .55em;
  font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 32px; height: 32px; color: var(--brand); }

.site-nav ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: .5em .85em; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: .96rem; text-decoration: none;
}
.site-nav a:hover { color: var(--text); background: var(--bg-alt); }
.site-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-50); }

.nav-toggle {
  display: none; width: 44px; height: 44px; padding: 10px;
  background: none; border: 0; cursor: pointer; border-radius: 8px;
}
.nav-toggle span { display: block; height: 2px; margin: 5px 0; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--bg); border-bottom: 1px solid var(--border);
    display: none; padding: 8px 16px 16px;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { padding: .8em 1em; }
}

/* ==========================================================================
   Hero + tool
   ========================================================================== */
.hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: #fff;
  padding: 56px 0 64px;
}
.hero-inner { max-width: 860px; text-align: center; }
.hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 800; }
.hero-sub { font-size: clamp(1rem, 2vw, 1.2rem); opacity: .92; max-width: 640px; margin: 0 auto 28px; }

.tool {
  background: var(--surface); color: var(--text);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; text-align: left;
}
.tool-row { display: flex; gap: 10px; }
.input-wrap {
  position: relative; flex: 1; display: flex; align-items: center;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--brand); }
.input-icon { width: 20px; height: 20px; margin-left: 14px; color: var(--text-muted); flex: none; }
.input-wrap input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--text); padding: .85em .75em;
}
.paste-btn {
  margin-right: 6px; padding: .45em .8em; border: 0; border-radius: 8px;
  background: var(--bg-alt); color: var(--text-muted); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.paste-btn:hover { color: var(--brand); }

.tool textarea {
  width: 100%; resize: vertical; min-height: 140px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: .9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: .8em;
}
.tool textarea:focus { outline: 0; border-color: var(--brand); }
.field-label { display: block; font-weight: 600; margin-bottom: 8px; }
.tool-actions { margin-top: 12px; display: flex; justify-content: center; }
.tool-hint { margin: 12px 2px 0; font-size: .85rem; color: var(--text-muted); }
.tool-hint a { color: inherit; }

.tool .spinner {
  display: none; width: 1.1em; height: 1.1em;
  border: 2.5px solid rgb(255 255 255 / .4); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.tool.is-loading .spinner { display: inline-block; }
.tool.is-loading [type="submit"] { pointer-events: none; opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

.tool-status:empty { display: none; }
.tool-status {
  margin-top: 14px; padding: .8em 1em; border-radius: var(--radius-sm);
  background: var(--danger-bg); color: var(--danger); font-size: .95rem;
}
.tool-status a { color: inherit; font-weight: 600; }

@media (max-width: 600px) {
  .hero { padding: 36px 0 44px; }
  .tool-row { flex-direction: column; }
  .tool-row .btn { width: 100%; }
}

/* Result card */
.result {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start;
  animation: fade-in .25s ease-out;
}
.result[hidden] { display: none; }
.result-thumb {
  width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #000;
  border-radius: var(--radius-sm); background: var(--bg-alt);
}
.result-title { font-size: 1.05rem; margin: 0 0 12px; overflow-wrap: anywhere; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.result-note { margin: 12px 0 0; font-size: .85rem; color: var(--text-muted); }
@media (max-width: 600px) { .result { grid-template-columns: 1fr; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }

/* ==========================================================================
   Sections
   ========================================================================== */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 36px; }

.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px;
}
.step {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; position: relative;
}
.step-num {
  display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 14px;
  border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 800;
}
.step h3 { font-size: 1.1rem; }
.step p { margin: 0; color: var(--text-muted); }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.feature { padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.feature-icon {
  width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 14px;
  border-radius: 12px; background: var(--brand-50); color: var(--brand);
}
.feature-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.feature h3 { font-size: 1.1rem; }
.feature p { margin: 0; color: var(--text-muted); }

.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.tool-card {
  display: block; padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--brand); transform: translateY(-2px); color: var(--text); }
.tool-card h3 { font-size: 1.1rem; color: var(--brand); }
.tool-card p { margin: 0; color: var(--text-muted); }

/* FAQ */
.faq-list { display: grid; gap: 12px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq-item summary {
  cursor: pointer; list-style: none; padding: 1em 3em 1em 1.2em; position: relative;
  font-weight: 600;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ""; position: absolute; right: 1.2em; top: 50%; width: 10px; height: 10px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg); transition: transform .2s;
}
.faq-item[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq-answer { padding: 0 1.2em 1em; color: var(--text-muted); }
.faq-answer p { margin: 0; }

/* Page header + prose */
.page-header { padding: 48px 0 24px; background: var(--bg-alt); border-bottom: 1px solid var(--border); }
.page-header h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
.lede { color: var(--text-muted); font-size: 1.1rem; margin: 0; }
.breadcrumbs { font-size: .9rem; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumbs a { color: inherit; }

.prose h2 { font-size: 1.5rem; margin-top: 1.8em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.4em; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .4em; }

.toc { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1em 1.3em; margin: 1.5em 0; }
.toc ol { margin: .5em 0 0; }

.cta-box {
  margin-top: 3em; padding: 32px; text-align: center; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff;
}
.cta-box h2 { margin-top: 0; color: #fff; }
.cta-box .btn { background: #fff; color: #1a5ce6; }

.contact-email { margin: 1.5em 0; }
.not-found { padding: 96px 0; border: 0; }
.big-code { font-size: 5rem; font-weight: 900; line-height: 1; color: var(--brand); margin-bottom: .2em; }
.not-found .btn { margin-top: 24px; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); padding: 48px 0 24px; font-size: .95rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer-note { color: var(--text-muted); margin-top: 12px; max-width: 320px; }
.footer-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer li a { color: var(--text); text-decoration: none; }
.site-footer li a:hover { color: var(--brand); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .85rem; }
.footer-bottom p { margin: 0; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

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