/* ============ 1. Reset & tokens ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }

:root {
  --bg: #0b1220;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --ink: #101828;
  --ink-soft: #4b5566;
  --line: #e2e6ef;
  --accent: #1d5bfa;
  --accent-ink: #0d3fc7;
  --accent-soft: #e7edff;
  --ok: #12805c;
  --err: #c0392b;
  --sans: "Inter", system-ui, sans-serif;
  --display: "Manrope", var(--sans);
  --radius: 14px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #121a2b;
    --surface-2: #182238;
    --ink: #eef1f8;
    --ink-soft: #a4adc2;
    --line: #26314a;
    --accent-soft: #17224a;
  }
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; }
p { text-wrap: pretty; }
code { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); padding: .1em .4em; border-radius: 5px; font-size: .9em; }

.skip-link { position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem; background: var(--accent); color: #fff; z-index: 9999; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 1.25rem; }

/* ============ 2. Header ============ */
.site-header { background: var(--bg); padding: 1rem 0; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.header-badge { color: #b9c4e0; font-size: .82rem; font-weight: 500; }

/* ============ 3. Hero & tool card ============ */
.hero { background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 55%, transparent 55%); padding-bottom: 2rem; }
.hero h1 { color: #fff; font-size: clamp(1.7rem, 4.5vw, 2.5rem); max-width: 20ch; }
.hero-sub { color: #c3ccdf; max-width: 56ch; margin-top: .8rem; font-size: 1.02rem; }

.tool-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px -20px rgba(10, 20, 50, .35);
  margin-top: 1.6rem;
  overflow: hidden;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  padding: 1rem .5rem;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 3px solid transparent;
  transition: color .2s var(--ease-out), border-color .2s var(--ease-out);
}
.tab.is-active { color: var(--accent); border-color: var(--accent); }
.tab:hover { color: var(--accent); }

.panel { padding: 1.5rem; display: none; }
.panel.is-active { display: block; }

.field-label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .5rem; }
.input-row { display: flex; gap: .5rem; }
#cufe-input, #cufe-bulk {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: .85rem 1rem;
  font-size: .98rem;
  font-family: ui-monospace, Menlo, monospace;
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color .2s var(--ease-out);
}
#cufe-input:focus, #cufe-bulk:focus { border-color: var(--accent); outline: none; }
#cufe-input.is-valid { border-color: var(--ok); }
#cufe-input.is-invalid { border-color: var(--err); }
#cufe-bulk { resize: vertical; font-size: .88rem; }

.hint { font-size: .84rem; color: var(--ink-soft); margin-top: .5rem; }
.hint.is-err { color: var(--err); font-weight: 600; }
.hint.is-ok { color: var(--ok); font-weight: 600; }

.btn { border-radius: 10px; font-weight: 700; transition: transform .15s var(--ease-out), background .2s var(--ease-out), opacity .2s; }
.btn:active { transform: scale(.98); }
.btn-ghost { background: var(--surface-2); padding: .85rem 1.1rem; white-space: nowrap; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-big { width: 100%; padding: 1rem; font-size: 1.02rem; margin-top: 1.1rem; }

.upload-row { margin-top: 1rem; }
.file-drop {
  display: flex; align-items: center; gap: .6rem;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: .9rem 1rem;
  color: var(--ink-soft);
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .2s var(--ease-out), background .2s var(--ease-out);
}
.file-drop:hover, .file-drop.is-drag { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }

.progress-wrap { margin-top: 1.2rem; }
.progress-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .25s var(--ease-out); }
.progress-label { font-size: .85rem; color: var(--ink-soft); margin-top: .5rem; }

.result-box { margin-top: 1.2rem; }
.result-box[hidden] { display: none; }

.result-single { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; border-radius: 10px; background: var(--surface-2); }
.result-single.is-invalid { background: #fdecea; }
.result-single h4 { font-size: .95rem; }
.result-single .code-preview { font-family: ui-monospace, monospace; font-size: .78rem; color: var(--ink-soft); word-break: break-all; }

.result-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.result-table th, .result-table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
.result-table td.status-ok { color: var(--ok); font-weight: 600; }
.result-table td.status-err { color: var(--err); font-weight: 600; }
.result-table a.rowlink { color: var(--accent); font-weight: 600; }
.result-summary { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; margin-bottom: .8rem; font-size: .9rem; }
.result-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.result-actions .btn { padding: .7rem 1.1rem; }

.privacy-badge { color: #b9c4e0; font-size: .85rem; margin-top: 1rem; text-align: center; }

/* ============ 4. Ad slots ============ */
.ad-slot {
  border: 1.5px dashed #c7cee0;
  border-radius: 10px;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  color: #8a93ab;
  font-size: .8rem;
  letter-spacing: .08em;
  background: var(--surface-2);
  margin: 1.5rem 0;
}
.ad-label { font-weight: 700; }
.ad-slot--leaderboard { min-height: 100px; }
.ad-slot--incontent { min-height: 250px; }
.ad-slot--inline { margin: .8rem 0 0; min-height: 70px; }
.ad-slot--modal { min-height: 200px; margin: 0 0 .8rem; width: 100%; }
.ad-slot--corner { min-height: 60px; width: 260px; margin: 0; }

.ad-modal { border: none; border-radius: var(--radius); padding: 1.2rem; max-width: 340px; width: 90vw; box-shadow: 0 30px 60px -20px rgba(0,0,0,.4); }
.ad-modal::backdrop { background: rgba(10, 16, 32, .55); }
.ad-modal-close { position: absolute; top: .6rem; right: .6rem; width: 32px; height: 32px; border-radius: 99px; background: var(--surface-2); font-size: 1rem; }
.ad-modal-note { font-size: .85rem; color: var(--ink-soft); text-align: center; }

.corner-toast { position: fixed; bottom: 1rem; right: 1rem; z-index: 500; display: flex; align-items: flex-start; gap: .4rem; animation: toast-in .3s var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.corner-toast-close { width: 26px; height: 26px; border-radius: 99px; background: var(--surface); box-shadow: 0 4px 10px rgba(0,0,0,.15); font-size: .8rem; }

/* ============ 5. Content sections ============ */
.content-section { padding: 3rem 1.25rem; color: #dfe4f0; }
.content-section h2 { color: #fff; font-size: 1.5rem; margin-bottom: 1.4rem; }
body { background: var(--bg); }
main { background: var(--bg); }
.content-section, .hero { color: inherit; }
.content-section p, .content-section h3 { color: #dfe4f0; }
.content-section h3 { color: #fff; font-size: 1.05rem; margin-bottom: .3rem; }

.steps { list-style: none; display: flex; flex-direction: column; gap: 1.4rem; }
.steps li { display: flex; gap: 1rem; align-items: flex-start; }
.step-num {
  flex: none; width: 34px; height: 34px; border-radius: 99px;
  background: var(--accent); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.steps p { color: #b9c4e0; font-size: .95rem; }

.uses-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.use-card { background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 1.1rem; }
.use-card h3 { font-size: 1rem; margin-bottom: .35rem; }
.use-card p { color: #b9c4e0; font-size: .9rem; }

.faq-list details {
  border-bottom: 1px solid rgba(255,255,255,.1);
  padding: 1rem 0;
}
.faq-list summary { font-weight: 700; color: #fff; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary::after { content: "+"; font-size: 1.3rem; color: var(--accent); flex: none; }
.faq-list details[open] summary::after { content: "–"; }
.faq-list p { color: #b9c4e0; margin-top: .6rem; font-size: .93rem; }

/* ============ 6. Footer ============ */
.site-footer { background: #060a14; padding: 2rem 0; }
.site-footer p { color: #7d879e; font-size: .82rem; max-width: 65ch; }
.site-footer nav { display: flex; gap: 1rem; margin-top: .8rem; }
.site-footer nav a { color: #b9c4e0; font-size: .82rem; font-weight: 600; }
.site-footer nav a:hover { color: #fff; }

/* ============ 7. Breakpoints ============ */
@media (min-width: 540px) {
  .input-row { flex-wrap: nowrap; }
}
@media (min-width: 720px) {
  .uses-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .wrap { padding: 0 1.5rem; }
}

/* ============ 8. Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .corner-toast { animation: none; }
  * { transition-duration: .001ms !important; }
}

/* No-JS fallback message on tool */
.needs-js { display: none; }
