/* koomen.dev look, ported from its Tailwind v4 + @tailwindcss/typography build */
:root {
  --font-sans: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5dc;
  --gray-400: #99a1af;
  --gray-500: #6a7282;
  --gray-600: #4a5565;
  --gray-700: #364153;
  --gray-800: #1e2939;
  --gray-900: #101828;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-600: #155dfc;
  --blue-700: #1447e6;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-700: #008236;
  --purple-50: #faf5ff;
  --purple-200: #e9d4ff;
  --purple-700: #8200db;
  --yellow-50: #fefce8;
  --yellow-200: #fff085;
  --yellow-700: #a65f00;
}

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

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

body {
  margin: 0;
  background: #ffffff;
  color: var(--gray-800);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { display: block; max-width: 100%; }

/* ---------- page frame ---------- */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
}

.site-name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1.75rem;
  letter-spacing: -0.025em;
  color: var(--gray-500);
}

.site-name a { color: inherit; text-decoration: none; }

.social {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
}

.social a { color: var(--gray-700); transition: color 0.15s; }
.social a:hover { color: var(--gray-900); }

main.prose { flex-grow: 1; padding: 1rem 0; }

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding: 1.5rem 0;
}

.made-with { margin: 0; font-size: 1rem; line-height: 1.5rem; }

.made-with a {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #000;
  text-decoration: none;
}

/* erga.dev/logo.png is 512×512 with the wordmark at x 70–444, y 188–310: show only that, 1.05rem tall */
.made-with .erga-mark { position: relative; top: 2px; margin-left: 2px; display: block; width: 3.22rem; height: 1.05rem; overflow: hidden; }
.made-with .erga-mark img { position: absolute; left: -0.603rem; top: -1.618rem; width: 4.407rem; height: auto; max-width: none; }

.copyright {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--gray-500);
}

/* ---------- prose (typography plugin defaults + site overrides) ---------- */
.prose {
  color: var(--gray-700);
  font-size: 1rem;
  line-height: 1.75;
}

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }

.prose p { margin: 1.25em 0; }

.prose a {
  color: var(--gray-900);
  font-weight: 500;
  text-decoration: none;
}

.prose a:hover { text-decoration: underline; }

.prose strong { color: var(--gray-900); font-weight: 600; }

.prose h1 {
  color: var(--gray-900);
  margin: 0 0 0.888889em;
  font-size: 2.25em;
  font-weight: 800;
  line-height: 1.11111;
}

.prose h2 {
  color: var(--gray-900);
  margin: 2em 0 1em;
  font-size: 1.5em;
  font-weight: 700;
  line-height: 1.33333;
}

.prose h3 {
  color: var(--gray-900);
  margin: 1.6em 0 0.6em;
  font-size: 1.25em;
  font-weight: 600;
  line-height: 1.6;
}

.prose h2 + *, .prose h3 + * { margin-top: 0; }

/* projects: a list of rows, each a thumbnail and then its name and description */
.projects { margin: 1.25em 0; }
.project {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.25rem;
  align-items: start;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--gray-200);
}
.project:first-child { padding-top: 0; }
.project:last-child { padding-bottom: 0; border-bottom: 0; }
@media (max-width: 480px) { .project { grid-template-columns: 1fr; gap: 0.75rem; } }
.prose .project h3 { margin: 0; font-size: 1rem; line-height: 1.5rem; font-weight: 600; }
.prose .project h3 a { font-weight: 600; }

.project .shot {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  transition: transform 0.15s, box-shadow 0.15s;
}
.project .shot:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); text-decoration: none; }
.project .shot img { width: 100%; height: 100%; object-fit: cover; }
.project .shot.crop-top img { object-position: top; }
.prose .project p { margin: 0.25rem 0 0; font-size: 0.9375rem; line-height: 1.6; }

/* a project shown by its logo: the logo centered on a soft card */
.project .shot.logo { display: grid; place-items: center; background: #f2fbe6; box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05); }
.project .shot.logo:hover { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06); }
.project .shot.logo img { width: 80%; height: auto; object-fit: contain; }

/* erga.dev/logo.png is square with the wordmark across its middle: full width, centred, the box crops the white above and below */
.project .shot.logo.erga-logo { position: relative; background: #fff; border-color: transparent; box-shadow: none; }
.project .shot.logo.erga-logo:hover { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06); }
.project .shot.logo.erga-logo img { position: absolute; left: 0; top: 50%; width: 100%; height: auto; transform: translateY(-48.6%); }

/* images/erga.png (2000×1226) shows only its editor, x 31–1969 and y 26–1118: no margin, no demo controls */
.project .shot.crop-erga { aspect-ratio: 1939 / 1093; border: 0; border-radius: 0.625rem; }
.project .shot.crop-erga img { width: 103.146%; max-width: none; height: auto; margin: -1.341% 0 0 -1.599%; object-fit: fill; }

.prose .date { margin-left: 0.5rem; font-size: 0.875rem; color: var(--gray-500); }

.prose .byline {
  margin: -0.75rem 0 2rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--gray-500);
}

.prose h2, .prose h3 { position: relative; }


.prose ol, .prose ul { margin: 1.25em 0; padding-inline-start: 1.625em; }
.prose ol { list-style-type: decimal; }
.prose ul { list-style-type: disc; }
.prose li { margin: 0.5em 0; padding-inline-start: 0.375em; }
.prose ol > li::marker { color: var(--gray-500); font-weight: 400; }
.prose ul > li::marker { color: var(--gray-300); }

.prose sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; top: -0.5em; }

.prose code {
  color: var(--gray-900);
  background: var(--gray-100);
  font-family: var(--font-mono);
  font-size: 0.9em;
  font-weight: 500;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.prose .thanks { margin-top: 4.75em; }

/* ---------- figures ---------- */
figure { margin: 2rem 0; }

.captioned-image img {
  width: 75%;
  margin: 0 auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.prose .caption {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--gray-500);
}

.captioned-text .box {
  width: 75%;
  margin: 0 auto;
  padding: 1rem;
  border-radius: 0.5rem;
  background: var(--gray-100);
  font-weight: 300;
}

.prose .captioned-text .box p { margin: 0; }
.prose .captioned-text .box p + p { margin-top: 1.25em; }

/* ---------- static snapshots of the interactive demos ---------- */
/* Demos break out of the text column, up to 56rem wide, centred on it; on a narrow screen they fit the column. */
.demo {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  margin-inline: calc((100% - min(56rem, 100vw - 3rem)) / 2);
  padding: 0;
}

.demo-box {
  border: 1px solid var(--gray-200);
  border-radius: 0.75rem;
  padding: 1.5rem;
  background: #fff;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  line-height: 1.5;
}

.prose .demo .caption { margin-top: 0.75rem; }

.demo-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.demo-grid-4 { display: grid; grid-template-columns: 1fr; gap: 1rem; }

@media (min-width: 768px) {
  .demo-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .demo-grid-4 { grid-template-columns: 1fr 1fr 1.5fr; align-items: end; }
}

.prose .demo-label {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 600;
  color: var(--gray-700);
}

.prose .demo-label + * { margin-top: 0; }

.field {
  border: 1px solid var(--gray-300);
  border-radius: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  background: #fff;
}

.field.mono { font-family: var(--font-mono); line-height: 1.43; height: 400px; overflow-y: auto; }
.field.inset { background: var(--gray-50); box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05); }
.field.tall { min-height: 24rem; padding: 1rem; }

.prose .field p { margin: 0; }
.prose .field p + p { margin-top: 1.25em; }
.prose .field .placeholder { color: var(--gray-400); font-style: italic; }

.prose .tabs { margin: 0 0 0.5rem; padding: 0; list-style: none; display: flex; gap: 0.25rem; }

.prose .tabs li {
  margin: 0;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1rem;
  border-radius: 0.25rem;
  background: var(--gray-100);
  color: var(--gray-700);
}

.prose .tabs li.active { background: var(--blue-600); color: #fff; }

.prose .tools { margin: 0 0 1rem; padding: 0; list-style: none; }

.prose .tools li {
  margin: 0 0 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  background: var(--gray-50);
}

.prose .tools code { font-size: 0.875rem; color: var(--gray-800); }

.prose .inbox {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--gray-300);
  border-radius: 0.5rem;
  background: var(--gray-50);
  box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
  overflow: hidden;
}

.prose .inbox li {
  margin: 0;
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  border-bottom: 1px solid var(--gray-800);
  position: relative;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.prose .inbox li:last-child { border-bottom: 0; }

.prose .inbox li::after {
  content: "▶";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--gray-400);
}

.prose .inbox strong { font-weight: 500; color: var(--gray-800); }
.prose .inbox .subject { font-size: 0.75rem; line-height: 1rem; color: var(--gray-600); }

.prose .demo-note {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1rem;
  color: var(--gray-400);
}

.prose .demo-note a { color: var(--gray-500); font-weight: 400; text-decoration: underline; }

/* system / user prompt diagram */
.diagram {
  margin: 2rem 0;
  padding: 1.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  background: #fff;
  line-height: 1.5;
}

.diagram .combined {
  border: 1px solid var(--purple-200);
  background: var(--purple-50);
  padding: 1rem;
  border-radius: 0.5rem;
}

.prose .diagram p { margin: 0; }

.prose .diagram .title { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.5rem; }
.prose .diagram .combined .title { color: var(--purple-700); }
.prose .diagram .llm .title { color: var(--yellow-700); }

.diagram .sys, .diagram .usr { padding: 0.75rem; border-radius: 0.25rem; border: 1px solid; }
.diagram .sys { border-color: var(--blue-100); background: rgb(239 246 255 / 0.5); margin-bottom: 0.5rem; }
.diagram .usr { border-color: var(--green-100); background: rgb(240 253 244 / 0.5); }

.prose .diagram .sys p, .prose .diagram .usr p { font-family: var(--font-mono); font-size: 0.75rem; line-height: 1rem; }
.prose .diagram .sys p { color: var(--blue-700); }
.prose .diagram .usr p { color: var(--green-700); }

.diagram .arrow { display: flex; justify-content: center; margin: 1rem 0; color: var(--gray-500); }

.diagram .llm {
  border: 1px solid var(--yellow-200);
  background: var(--yellow-50);
  padding: 1rem;
  border-radius: 0.5rem;
}

.prose .diagram .llm .body { font-size: 0.875rem; color: var(--gray-700); }

/* part navigation (the essay is split in two files) */
.prose .part-nav {
  margin: 2.5em 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  font-size: 0.875rem;
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  /* the original site only themes the prompt diagram for dark mode */
  .diagram { background: var(--gray-800); border-color: var(--gray-700); }
  .diagram .combined { background: rgb(89 22 139 / 0.2); border-color: #6e11b0; }
  .diagram .sys { background: rgb(28 57 142 / 0.1); border-color: #1c398e; }
  .diagram .usr { background: rgb(13 84 43 / 0.1); border-color: #0d542b; }
  .diagram .llm { background: rgb(115 62 10 / 0.2); border-color: #894b00; }
  .prose .diagram .combined .title { color: #dab2ff; }
  .prose .diagram .sys p { color: #8ec5ff; }
  .prose .diagram .usr p { color: #7bf1a8; }
  .prose .diagram .llm .title { color: #ffdf20; }
  .prose .diagram .llm .body { color: var(--gray-300); }
  .diagram .arrow { color: var(--gray-400); }
}

.demo-grid-4 .field { margin-bottom: 0; }
