@font-face {
  font-family: Fraunces;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/fraunces-700.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
}

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #12110f;
  --muted: #5c574e;
  --border: #e0d7c8;
  --primary: #0a7a56;
  --primary-hover: #086345;
  --primary-tint: #e7f6ef;
  --secondary: #1e3a5f;
  --low: #b91c1c;
  --mid: #c2410c;
  --high: #0a7a56;
  --prompt: #141210;
  --prompt-ink: #f5f1e8;
  --shadow-sm: 0 1px 2px rgba(18, 17, 15, 0.06);
  --shadow-md: 0 4px 16px rgba(18, 17, 15, 0.08);
  --font-display: Fraunces, Georgia, serif;
  --font-ui: Inter, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --wrap: 1120px;
  --r-control: 8px;
  --r-card: 12px;
  --r-shell: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
}
img { max-width: 100%; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  left: 16px;
  top: -4rem;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 12px;
  border-radius: var(--r-control);
  z-index: 6;
}
.skip:focus { top: 8px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.wrap {
  width: min(var(--wrap), calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(246, 244, 239, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.brand img { width: 28px; height: 28px; display: block; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a {
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 500;
}
.nav a[aria-current="page"] {
  background: var(--primary-tint);
  color: var(--primary);
}
.nav-toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--r-control);
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
}
h2 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.3;
  margin: 2rem 0 0.6rem;
}
h3 { font-weight: 600; font-size: 1.125rem; margin: 1.4rem 0 0.4rem; }
.page-head { padding: 32px 0 8px; }
.deck { color: var(--muted); max-width: 62ch; margin: 0; font-size: 1.0625rem; line-height: 1.6; }
.meta {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}
.updated { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 0; }
.updated span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.updated time { font-family: var(--font-mono); font-size: 0.875rem; }
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.875rem;
  margin: 24px 0 0;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.trust-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.trust-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

.button, button, .tag-row button {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-control);
  padding: 10px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
}
.button.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.button.primary:hover, button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.secondary, button.secondary {
  background: var(--surface);
  border-color: var(--secondary);
  color: var(--secondary);
}
button.ghost, .button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
#optimize { position: relative; min-width: 9.25rem; }
#optimize::after {
  content: "";
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid transparent;
  border-radius: 50%;
}
#optimize.is-busy::after {
  border-color: #fff;
  border-right-color: transparent;
  animation: spin 0.6s linear infinite;
}
#copy-in { min-width: 8.75rem; }
#copy-out { min-width: 11rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.tool {
  margin: 24px 0 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-shell);
  box-shadow: var(--shadow-md);
  padding: 24px;
  min-width: 0;
}
#tool-label {
  margin: 0 0 16px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.empty-state { display: none; margin-bottom: 24px; }
.tool.is-empty .empty-state { display: block; }
.tool.is-empty .metrics,
.tool.is-empty .tool-extra,
.tool.is-empty #delta { display: none; }
.empty-panel {
  border: 1px dashed var(--border);
  border-radius: var(--r-card);
  background: var(--bg);
  padding: 24px;
  text-align: center;
}
.empty-panel svg { display: block; margin: 0 auto 12px; }
.empty-panel p { margin: 0 0 16px; color: var(--ink); }
.starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.starters button { border-radius: 999px; background: var(--surface); font-weight: 500; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
  min-width: 0;
}
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.metric > span {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.metric > strong {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.1;
}
.gauge {
  position: relative;
  width: 88px;
  height: 88px;
}
.gauge svg { width: 88px; height: 88px; transform: rotate(-90deg); display: block; }
.gauge-track, .gauge-value { fill: none; stroke-width: 6; }
.gauge-track { stroke: var(--border); }
.gauge-value {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 175.93;
  stroke-dashoffset: 175.93;
  transition: stroke-dashoffset 420ms ease;
}
.gauge[data-band="low"] .gauge-value { stroke: var(--low); }
.gauge[data-band="mid"] .gauge-value { stroke: var(--mid); }
.gauge[data-band="high"] .gauge-value { stroke: var(--high); }
.gauge strong, .gauge em {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-style: normal;
}
.gauge strong {
  top: 28px;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 400;
}
.gauge em {
  top: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.gauge[data-band="low"] em { color: var(--low); }
.gauge[data-band="mid"] em { color: var(--mid); }
.gauge[data-band="high"] em { color: var(--high); }
.metric > strong.delta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 400;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  min-width: 0;
}
.editor-in, .editor-out, .row, .tool { min-width: 0; }
.editor-in label, .editor-out label { font-weight: 600; margin: 0 0 8px; display: block; }
textarea, input[type="text"], input[type="email"], input[type="search"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  padding: 12px;
  min-height: 44px;
}
textarea {
  min-height: 16rem;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.editor-in textarea, .editor-out textarea {
  background: var(--prompt);
  color: var(--prompt-ink);
  border: 1px solid #2c2824;
}
.editor-out textarea { border-left: 2px solid var(--primary); }
.editor-out.is-blank textarea { color: #b7aea3; }
.editor-foot {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#delta { margin: 8px 0 0; color: var(--muted); font-size: 0.875rem; }
#delta:empty { display: none; }
.fine { color: var(--muted); font-size: 0.875rem; line-height: 1.5; margin: 16px 0 0; }
.tool-extra { margin-top: 8px; }
.insights { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.insight {
  margin: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
}
.insight.warn { background: #ffedd5; color: #9a3412; }
.insight.win { background: #d1fae5; color: #065f46; }
.cost-label { font-weight: 700; margin: 20px 0 12px; }
.cost-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.cost-card {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.cost-name, .cost-value { margin: 0; }
.cost-name { color: var(--muted); font-size: 0.8125rem; font-weight: 600; margin-bottom: 8px; }
.cost-value { font-family: var(--font-mono); font-size: 1.25rem; }
.cost-bar-track {
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.cost-bar { height: 6px; border-radius: 999px; background: var(--primary); }

.learn-more { margin: 8px 0 32px; }
.learn-more > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.125rem;
}
.guide-layout { margin-top: 8px; }
.prose, .post {
  font-size: 1.0625rem;
  line-height: 1.7;
  max-width: 68ch;
}
.prose a, .post a { text-underline-offset: 2px; }
.prose pre, .post pre, .prompt-sample {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  background: var(--prompt);
  color: var(--prompt-ink);
  padding: 16px;
  border-radius: var(--r-card);
  overflow-x: auto;
  white-space: pre-wrap;
}
.toc-desktop, .toc-mobile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.toc-desktop ol, .toc-mobile ol { margin: 8px 0 0; padding-left: 1.2rem; }
.toc-desktop a, .toc-mobile a { text-decoration: none; color: var(--ink); }
.toc-desktop a.is-active { color: var(--primary); font-weight: 700; }
.toc-mobile { margin: 16px 0; }
.toc-mobile summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.toc-desktop { display: none; }
.return { margin: 24px 0; }
.faq details { border-top: 1px solid var(--border); padding: 4px 0; }
.faq summary {
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.faq details[open] { background: var(--primary-tint); border-radius: var(--r-card); padding: 8px 16px 12px; margin: 8px 0; }

.blog-tools { margin: 20px 0 8px; }
#blog-search { max-width: 420px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag-row button { border-radius: 999px; min-height: 40px; font-weight: 600; }
.tag-row button .count { font-family: var(--font-mono); font-weight: 400; opacity: 0.8; }
.tag-row button.chip-cost { color: #0a7a56; border-color: #9ddec4; }
.tag-row button.chip-tokens { color: #1d4ed8; border-color: #bfdbfe; }
.tag-row button.chip-prompting { color: #7c3aed; border-color: #ddd6fe; }
.tag-row button.chip-models { color: #0891b2; border-color: #a5f3fc; }
.tag-row button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.cards { display: grid; grid-template-columns: 1fr; gap: 16px; margin: 16px 0 24px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.card:hover { box-shadow: var(--shadow-md); }
.card h2 { margin: 0; font-size: 1.125rem; }
.card p { margin: 0; }
.card .excerpt {
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--ink);
}
.chip-cost { background: #e7f6ef; color: #0a7a56; }
.chip-tokens { background: #e8eefb; color: #1d4ed8; }
.chip-prompting { background: #f3e8ff; color: #7c3aed; }
.chip-models { background: #e0f7fa; color: #0891b2; }
.chip-neutral { background: var(--bg); color: var(--ink); }
.blog-note, .blog-empty { max-width: 68ch; color: var(--muted); }

.page-narrow { max-width: 720px; }
.publisher-card, .contact-card, .callout, .thanks, .trust-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.about-logo { width: 64px; height: 64px; display: block; margin: 8px 0 16px; }
.publisher-card { display: flex; gap: 16px; margin: 16px 0 24px; }
.avatar {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
}
.publisher-name { font-family: var(--font-display); font-size: 1.5rem; margin: 0; }
.trust-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 8px 0 24px; }
.trust-card h2 { margin-top: 0; font-size: 1.05rem; }
.trust-card p { margin: 0; color: var(--muted); }
.actions, .post-nav, .related { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.related a, .post-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
}
.contact-card { max-width: 560px; margin: 24px auto; position: relative; }
.contact-card .field { margin-top: 16px; }
.contact-card label { display: block; font-weight: 600; margin: 0 0 8px; }
.contact-card textarea { font-family: var(--font-ui); font-size: 1rem; min-height: 10rem; }
.contact-card button[type="submit"] { min-width: 10.5rem; margin-top: 16px; }
.field-error { color: var(--low); font-size: 0.875rem; margin: 6px 0 0; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--low); }
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.thanks { max-width: 560px; margin: 24px auto; }
.thanks h2 { margin-top: 0; }
.callout {
  background: #fff7ed;
  border-left: 4px solid var(--mid);
  margin: 16px 0 24px;
}
.post-end { margin-top: 48px; max-width: 68ch; }

.back-to-tool, .back-to-top {
  display: none;
  position: fixed;
  z-index: 3;
  min-height: 44px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  font-weight: 600;
}
.back-to-tool { left: 16px; right: 16px; bottom: 12px; }
.back-to-top { right: 16px; bottom: 16px; padding: 0 16px; }
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 32px 0 48px;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; }
.site-footer a { color: var(--ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.brand-line { color: var(--ink); font-weight: 700; margin: 0 0 4px; }
.brand-note { margin: 0 0 8px; }

@media (min-width: 700px) {
  .cost-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trust-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 800px) {
  .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .tool-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .guide-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }
  .guide-layout > .prose,
  .guide-layout > .post,
  .guide-layout > article { grid-column: 2; grid-row: 1; max-width: none; }
  .toc-mobile { display: none; }
  .toc-desktop {
    display: block;
    position: sticky;
    top: 88px;
    grid-column: 1;
    grid-row: 1;
  }
}
@media (min-width: 1100px) {
  .cards { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 767px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 8px 16px 16px;
  }
  .nav-open .nav { display: flex; }
  .tool { padding: 16px; }
  .back-to-tool.is-visible { display: flex; }
  body:has(.back-to-tool.is-visible) { padding-bottom: 72px; }
}
@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .learn-more > summary { font-family: var(--font-display); font-size: 1.75rem; }
}
.back-to-top.is-visible { display: inline-flex; }

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