:root {
  --ink: #111712;
  --paper: #f4f0e6;
  --surface: #fffdf8;
  --acid: #d8ff43;
  --coral: #ff6e4a;
  --blue: #85b8ff;
  --line: rgba(17, 23, 18, 0.22);
  --muted: #687069;
  --display: "Bodoni 72", Didot, "Iowan Old Style", Georgia, serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --sans: Avenir, "Avenir Next", Montserrat, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

button, input, textarea { font: inherit; }
a { color: inherit; }

button:focus-visible,
a:focus-visible,
label:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 1rem;
  left: 1rem;
  padding: 0.75rem;
  transform: translateY(-180%);
  background: var(--ink);
  color: white;
}
.skip-link:focus { transform: none; }

.grid-bg {
  position: fixed;
  z-index: -1;
  inset: 0;
  opacity: 0.42;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}

.site-header,
footer {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--mono);
  font-weight: 800;
  letter-spacing: -0.06em;
  text-decoration: none;
}

.brand em {
  color: var(--coral);
  font-family: var(--display);
  font-weight: 400;
}

.brand-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid;
  background: var(--acid);
  font-size: 0.68rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.7rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-header nav a { text-decoration: none; }
.site-header nav a:not(.host-link):hover { text-decoration: underline 2px; text-underline-offset: 5px; }

.host-link {
  padding: 0.7rem 0.9rem;
  background: var(--ink);
  color: white;
}
.host-link:hover { background: var(--acid); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }

.hero {
  width: min(1360px, calc(100% - 64px));
  margin: 0 auto;
  padding: clamp(5rem, 10vw, 9rem) 0 clamp(3rem, 7vw, 6rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.4fr);
  gap: clamp(3rem, 8vw, 8rem);
  align-items: end;
}

.hero > * { min-width: 0; }

.eyebrow,
.section-label {
  margin: 0 0 1.25rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow span {
  display: inline-block;
  padding: 0.35rem 0.5rem;
  border: 1px solid;
  background: var(--acid);
  transform: rotate(-1deg);
}

.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(5.5rem, 11vw, 10rem);
  font-weight: 500;
  line-height: 0.76;
  letter-spacing: -0.07em;
}

.hero h1 i {
  color: var(--coral);
  font-weight: 400;
}

.hero-copy {
  margin: 0 0 0.4rem;
  padding-top: 1.5rem;
  border-top: 1px solid;
  font-size: clamp(1rem, 1.4vw, 1.22rem);
  line-height: 1.65;
}

.converter {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  border: 1px solid;
  background: var(--ink);
  box-shadow: 14px 14px 0 var(--coral);
}

.converter-bar {
  min-height: 52px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.converter-bar i,
.portable-status i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 4px rgba(216,255,67,0.14);
}

.converter-bar span:last-child { color: #aeb6af; }

.workspace {
  min-height: 580px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid;
  border-bottom: 1px solid;
  background: var(--surface);
}

.pane { min-width: 0; display: flex; flex-direction: column; }
.editor-pane { border-right: 1px solid; }

.pane-bar {
  min-height: 48px;
  padding: 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.pane-bar > span:first-child { font-weight: 800; }
.pane-bar > span:first-child::before { content: "●"; margin-right: 0.55rem; color: var(--coral); }
.pane-bar > span:nth-child(2) { color: var(--muted); }
.pane-bar > div { margin-left: auto; display: flex; gap: 0.35rem; }

.pane-bar button,
.pane-bar label {
  padding: 0.35rem 0.45rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
}
.pane-bar button:hover,
.pane-bar label:hover { background: var(--acid); }

#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

#html-input {
  width: 100%;
  min-height: 532px;
  flex: 1;
  resize: none;
  padding: 1.1rem 1.25rem;
  border: 0;
  outline: 0;
  background: #171d18;
  color: #e8efe9;
  caret-color: var(--acid);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.68;
  tab-size: 2;
  white-space: pre;
}

.preview-pane .pane-bar { justify-content: space-between; background: #f0ece3; }
.preview-pane small { padding: 0.25rem 0.4rem; border: 1px solid #47704e; background: #e7f5e5; color: #29522f; text-transform: uppercase; }

#preview-frame { width: 100%; min-height: 532px; flex: 1; border: 0; background: white; }

.result {
  padding: clamp(1.1rem, 2.2vw, 1.8rem);
  display: grid;
  grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr) auto;
  gap: 0.9rem 1.3rem;
  align-items: center;
  background: var(--acid);
}

.result-copy strong,
.result-meta,
.generate {
  font-family: var(--mono);
  text-transform: uppercase;
}

.result-copy strong { font-size: 0.68rem; letter-spacing: 0.08em; }
.result-copy p { margin: 0.4rem 0 0; font-size: 0.75rem; line-height: 1.45; }
.result-copy p[data-level="warning"] { color: #6c4800; }
.result-copy p[data-level="error"] { color: #8a2410; }

.result-field {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  border: 1px solid;
  background: var(--surface);
  box-shadow: 4px 4px 0 rgba(17,23,18,0.24);
}

.result-field input {
  min-width: 0;
  height: 46px;
  padding: 0 0.8rem;
  border: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.66rem;
}

.result-field button {
  border: 0;
  border-left: 1px solid;
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}
.result-field button:hover { background: var(--blue); }
.result-field button:disabled { cursor: not-allowed; opacity: 0.45; }

.result-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.3rem;
  font-size: 0.62rem;
}
.result-meta b { margin-left: 0.3rem; }

.generate {
  grid-column: 3;
  grid-row: 1 / span 2;
  min-width: 200px;
  height: 66px;
  padding: 0 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 800;
  transition: 150ms ease;
}
.generate:hover:not(:disabled) { background: var(--coral); color: var(--ink); box-shadow: 5px 5px 0 var(--ink); transform: translate(-3px,-3px); }
.generate:disabled { cursor: wait; opacity: 0.75; }

.how {
  width: min(1280px, calc(100% - 64px));
  margin: clamp(7rem, 12vw, 11rem) auto;
}
.section-label { padding-bottom: 0.8rem; border-bottom: 1px solid; }

.how-grid {
  padding-top: 2.5rem;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: clamp(3rem, 8vw, 8rem);
}

.how h2,
.hosted h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.4rem, 6.5vw, 6.8rem);
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: -0.055em;
}

.how ol { margin: 0; padding: 0; list-style: none; }
.how li { padding: 1.3rem 0; display: grid; grid-template-columns: 48px 1fr; gap: 1rem; border-bottom: 1px solid; }
.how li:first-child { padding-top: 0; }
.how li > span { color: var(--muted); font-family: var(--mono); font-size: 0.68rem; }
.how h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.how li p { margin: 0; color: var(--muted); line-height: 1.55; }

.hosted {
  width: min(1280px, calc(100% - 64px));
  margin: 0 auto clamp(7rem, 12vw, 11rem);
  padding: clamp(2rem, 5vw, 5rem);
  display: grid;
  grid-template-columns: 1fr minmax(280px, 0.5fr);
  gap: clamp(3rem, 8vw, 8rem);
  align-items: end;
  border: 1px solid;
  background: var(--blue);
  box-shadow: 12px 12px 0 var(--ink);
}

.hosted > div > p:last-child { max-width: 44rem; margin: 1.8rem 0 0; line-height: 1.65; }

.hosted > a {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  background: var(--ink);
  color: white;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}
.hosted > a:hover { background: var(--acid); color: var(--ink); }

footer {
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 1.5rem;
  bottom: 1.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid;
  background: var(--ink);
  color: white;
  box-shadow: 5px 5px 0 var(--coral);
  font-family: var(--mono);
  font-size: 0.68rem;
  opacity: 0;
  transform: translateY(12px);
  transition: 160ms ease;
  pointer-events: none;
}
.toast.visible { opacity: 1; transform: none; }

body:not(.ready) .hero > *,
body:not(.ready) .converter { opacity: 0; transform: translateY(15px); }
.ready .hero > *,
.ready .converter { animation: arrive 560ms ease both; }
.ready .hero-copy { animation-delay: 100ms; }
.ready .converter { animation-delay: 180ms; }
@keyframes arrive { to { opacity: 1; transform: none; } }

/* Shared-page viewer */
.viewer-body { min-height: 100vh; overflow: hidden; background: #ebe8df; }

.viewer-header {
  height: 54px;
  padding: 0 0.8rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--ink);
  color: white;
}

.viewer-brand { color: white; font-size: 0.82rem; }
.viewer-brand .brand-icon { width: 31px; height: 31px; color: var(--ink); box-shadow: 2px 2px 0 var(--coral); }
.portable-status { font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; }
.viewer-header nav { display: flex; justify-content: flex-end; gap: 0.5rem; }
.viewer-header nav a { padding: 0.55rem 0.7rem; font-family: var(--mono); font-size: 0.6rem; text-decoration: none; text-transform: uppercase; }
.viewer-host { background: var(--acid); color: var(--ink); }
.viewer-header nav a:hover { color: var(--acid); }
.viewer-header nav .viewer-host:hover { background: var(--coral); color: var(--ink); }

.viewer-main { position: relative; height: calc(100vh - 54px); }
#page-frame { width: 100%; height: 100%; border: 0; background: white; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}
.loading > i { width: 40px; height: 40px; margin: auto; border: 2px solid; border-right-color: var(--coral); border-radius: 50%; animation: spin 650ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.viewer-error {
  width: min(650px, calc(100% - 40px));
  margin: 12vh auto 0;
  padding: clamp(2rem, 5vw, 4rem);
  border: 1px solid;
  background: var(--surface);
  box-shadow: 10px 10px 0 var(--coral);
}
.viewer-error > span { font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase; }
.viewer-error h1 { margin: 1.3rem 0; font-family: var(--display); font-size: clamp(3rem, 7vw, 5rem); font-weight: 500; line-height: 0.9; }
.viewer-error p { color: var(--muted); line-height: 1.55; }
.viewer-error a { display: inline-block; margin-top: 0.8rem; padding: 0.8rem; background: var(--ink); color: white; font-family: var(--mono); font-size: 0.65rem; text-decoration: none; text-transform: uppercase; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid; }
  .result { grid-template-columns: 1fr auto; }
  .result-copy, .result-field, .result-meta { grid-column: 1; }
  .generate { grid-column: 2; grid-row: 1 / span 3; height: 100%; }
}

@media (max-width: 760px) {
  .site-header,
  .converter,
  footer { width: calc(100% - 24px); }
  .site-header nav a:not(.host-link) { display: none; }
  .host-link { padding: 0.6rem; font-size: 0.58rem; }
  .hero,
  .how,
  .hosted { width: calc(100% - 32px); }
  .hero { grid-template-columns: 1fr; padding-top: 4rem; }
  .hero h1 { font-size: clamp(3.9rem, 16vw, 6.2rem); }
  .converter { box-shadow: 8px 8px 0 var(--coral); }
  .converter-bar span:last-child,
  .preview-pane small,
  #byte-count { display: none; }
  #html-input,
  #preview-frame { min-height: 420px; }
  .result { display: block; }
  .result-field { margin: 0.9rem 0; grid-template-columns: minmax(0, 1fr) auto; }
  #open-button { display: none; }
  .result-meta { margin-bottom: 0.9rem; }
  .generate { width: 100%; min-height: 58px; }
  .how-grid,
  .hosted { grid-template-columns: 1fr; }
  .hosted { padding: 1.5rem; box-shadow: 8px 8px 0 var(--ink); }
  .viewer-header { grid-template-columns: 1fr auto; }
  .portable-status,
  .viewer-header nav a:first-child { display: none; }
}

@media (max-width: 600px) {
  .site-header { min-height: 68px; }
  .brand { font-size: 0.82rem; }
  .brand-icon { width: 33px; height: 33px; }
  .host-link { font-size: 0; }
  .host-link::before { content: "Host ↗"; font-size: 0.58rem; }
  .hero h1 { font-size: clamp(3.5rem, 14.5vw, 4.7rem); }
  .pane-bar label,
  #sample-button { display: none; }
  #html-input { padding: 0.9rem; font-size: 0.74rem; }
  .result-meta { display: grid; gap: 0.45rem; }
  footer { min-height: 90px; font-size: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
