/* agent-sandboxing site: one long article per language, inside the cocode.dk brand frame.
   Calm pine-green accent; system fonts only (CJK faces listed for the Chinese page); light and dark. */
:root {
  --paper: #f7f6f2;
  --sheet: #ffffff;
  --ink: #1c2321;
  --muted: #59625f;
  --rule: #d9dcd6;
  --accent: #2f6b5c;
  --on-accent: #ffffff;
  --tint: #e4efea;
  --code-bg: #1e2624;
  --code-ink: #e6ece9;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --measure: 44rem;
  --wrap: 1120px;
  --gutter: 20px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141917;
    --sheet: #1b211f;
    --ink: #e7ebe8;
    --muted: #a3ada9;
    --rule: #2f3835;
    --accent: #86c8b4;
    --on-accent: #10211c;
    --tint: #20302b;
    --code-bg: #0d1110;
    --code-ink: #dfe7e3;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans); overflow-wrap: break-word;
}
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
/* The brand frame lines up with this column. */
cocode-head, cocode-foot { --cocode-max: var(--wrap); --cocode-gutter: var(--gutter); }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }

/* ---------- skip link ---------- */
.skip {
  position: absolute; inset-inline-start: 8px; top: -100px; z-index: 10;
  padding: 10px 16px; background: var(--accent); color: var(--on-accent); border-radius: 4px;
}
.skip:focus { top: 8px; }

/* ---------- article ---------- */
.article { padding: 24px 0 64px; }
.article-head { padding-bottom: 24px; border-bottom: 1px solid var(--rule); }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 7vw, 3rem); font-weight: 750; letter-spacing: -.02em; max-width: 20ch; }
h2 { font-size: clamp(1.4rem, 4vw, 1.85rem); font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.2rem; font-weight: 650; margin-top: 28px; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: var(--measure); margin: 16px 0 0; }
.source { margin: 16px 0 0; font-weight: 600; }
section { padding-top: 40px; max-width: var(--measure); scroll-margin-top: 16px; }
section p, section ul, section ol { margin: 14px 0 0; }
section ul { padding-inline-start: 1.3em; }
section li + li { margin-top: 6px; }
blockquote { margin: 18px 0 0; padding: 4px 0 4px 16px; border-inline-start: 3px solid var(--accent); color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: .95rem; display: block; overflow-x: auto; }
th, td { text-align: start; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); }

/* ---------- language switcher ---------- */
.lang-switch ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.lang-switch a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .95rem;
}
.lang-switch a:hover { border-color: var(--accent); color: var(--accent); }
.lang-switch a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- table of contents ---------- */
.toc { margin-top: 24px; padding: 16px 18px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; }
.toc-title { margin: 0; font-weight: 700; font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc ol { margin: 8px 0 0; padding-inline-start: 1.4em; }
.toc li { margin: 4px 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- numbered steps ---------- */
ol.steps { list-style: none; padding: 0; counter-reset: step; }
ol.steps > li { counter-increment: step; position: relative; padding-inline-start: 3rem; min-height: 2.2rem; }
ol.steps > li + li { margin-top: 20px; }
ol.steps > li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  width: 2.2rem; height: 2.2rem; display: grid; place-items: center;
  background: var(--tint); color: var(--accent); border-radius: 50%; font-weight: 700; font-size: .95rem;
}

/* ---------- code ---------- */
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code { font-size: .9em; background: var(--tint); padding: .08em .35em; border-radius: 4px; }
.code { position: relative; margin-top: 14px; }
.code pre {
  margin: 0; padding: 16px 18px; padding-top: 44px; background: var(--code-bg); color: var(--code-ink);
  border-radius: 8px; font-size: .88rem; line-height: 1.6; overflow-x: auto; tab-size: 2;
}
.code pre code { background: none; padding: 0; white-space: pre; }
.copy-btn {
  position: absolute; top: 6px; inset-inline-end: 6px; min-height: 32px; min-width: 44px; padding: 0 12px;
  font: 600 .8rem var(--sans); color: var(--code-ink); background: transparent;
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 6px; cursor: pointer;
}
.copy-btn:hover { border-color: var(--code-ink); }
.copy-btn[data-state="copied"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* ---------- Chinese ---------- */
body:lang(zh) { line-height: 1.85; letter-spacing: .01em; }
:lang(zh) h1, :lang(zh) h2, :lang(zh) h3 { letter-spacing: 0; line-height: 1.35; }
:lang(zh) h1 { max-width: 16em; }
:lang(zh) .toc-title { text-transform: none; letter-spacing: .1em; }
:lang(zh) em { font-style: normal; text-emphasis: dot; }

/* ---------- wider screens: table of contents beside the text ---------- */
@media (min-width: 768px) {
  :root { --gutter: 32px; }
  .article { padding-top: 40px; }
  section { padding-top: 56px; }
}
@media (min-width: 1024px) {
  .article { display: grid; grid-template-columns: minmax(0, var(--measure)) minmax(12rem, 16rem); column-gap: 56px; }
  .article-head { grid-column: 1 / -1; }
  .article > section { grid-column: 1; }
  /* Spans every row the sections create, so it can stay in view while they scroll past. */
  .toc { grid-column: 2; grid-row: 2 / span 99; align-self: start; position: sticky; top: 16px; margin-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
@media print {
  .lang-switch, .toc, .copy-btn, .skip, cocode-head, cocode-foot { display: none; }
  .code pre { background: none; color: inherit; border: 1px solid var(--rule); padding-top: 16px; }
}
