/*
 * kapelle.dev — one stylesheet for every page.
 *
 * Two fonts, both self-hosted under the SIL Open Font License (see fonts/):
 * Fraunces for text and headings, Martian Mono for menus, buttons and code.
 * The TUI figures use the system's own monospace font, as a terminal would.
 *
 * Light is the default. Dark follows the system, unless the person picks a
 * theme in the footer: site.js then sets data-theme on <html>.
 */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("/fonts/martian-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --serif: "Fraunces", Georgia, serif;
  --mono: "Martian Mono", ui-monospace, Menlo, Consolas, monospace;
  --term: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #eeeae4;
  --band: #e7e2db;
  --surface: #f6f3ef;
  --code-bg: #e4ded6;
  --text: #1e2631;
  --muted: #59616b;
  --line: #d3cbc1;
  --blue: #1d6e9c;
  --purple: #7a4aa3;
  --amber: #985814;
  --green: #3e7a4e;
  --pink: #a3326f;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --band: #0f1318;
    --surface: #181d24;
    --code-bg: #0e1116;
    --text: #e3e6e9;
    --muted: #9aa3ae;
    --line: #2a313b;
    --blue: #5cc8ff;
    --purple: #c792ea;
    --amber: #ffb454;
    --green: #7fd99a;
    --pink: #ff6ac1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c;
  --band: #0f1318;
  --surface: #181d24;
  --code-bg: #0e1116;
  --text: #e3e6e9;
  --muted: #9aa3ae;
  --line: #2a313b;
  --blue: #5cc8ff;
  --purple: #c792ea;
  --amber: #ffb454;
  --green: #7fd99a;
  --pink: #ff6ac1;
  color-scheme: dark;
}

/* ---- base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 24px;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-wrap: pretty;
  overflow-x: clip;
}
a {
  color: var(--blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
em {
  font-style: italic;
}
code,
pre,
kbd {
  font-family: var(--mono);
  font-size: 0.72em;
}
p code,
li code,
td code,
dd code {
  font-size: 0.74em;
  overflow-wrap: anywhere;
}
pre {
  margin: 0;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px;
  line-height: 1.85;
  overflow-x: auto;
  font-size: 13px;
}
pre .c {
  color: var(--muted);
}
.mono {
  font-family: var(--mono);
}
.muted {
  color: var(--muted);
}
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}
.narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- the strip, the header and the footer ---- */

.strip {
  background: var(--band);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
  padding: 9px 16px;
  color: var(--muted);
}
.soon {
  color: var(--amber);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 68px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 15px;
}
.brand:hover {
  text-decoration: none;
}
.brand .crumb {
  color: var(--muted);
  font-weight: 400;
}
.nav {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
}
.nav a {
  color: var(--muted);
}
.nav a[aria-current="page"] {
  color: var(--text);
}
.nav-end {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.site-footer {
  border-top: 1px solid var(--line);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 40px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.theme-picker {
  display: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.js .theme-picker {
  display: flex;
}
.theme-picker button {
  background: transparent;
  color: var(--muted);
  border: 0;
  font: inherit;
  padding: 8px 14px;
  min-height: 36px;
  cursor: pointer;
}
.theme-picker button[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

/* ---- buttons, tabs and the install box ---- */

.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--text);
  border-radius: 4px;
  padding: 12px 18px;
}
.btn:hover {
  text-decoration: none;
  background: var(--surface);
}
.btn.quiet {
  color: var(--muted);
  border-color: var(--line);
}
.install {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  text-align: left;
}
.install .tabs {
  display: none;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  align-items: stretch;
}
.js .install .tabs {
  display: flex;
}
.install .tabs button {
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
}
.install .tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--text);
}
.install .tabs .soon {
  margin-left: auto;
  align-self: center;
  padding: 0 14px;
}
.install .panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}
.install .panel[hidden] {
  display: none;
}
.install .panel + .panel {
  border-top: 1px solid var(--line);
}
.js .install .panel + .panel {
  border-top: 0;
}
.install .panel pre {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.8;
}
.install .label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.js .install .label {
  display: none;
}
.copy {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.js .copy {
  display: inline-block;
}

/* ---- figures ---- */

figure {
  margin: 0;
}
figcaption {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.figure-center figcaption {
  text-align: center;
}
.scroll-x {
  overflow-x: auto;
  max-width: 100%;
}

/* ---- home ---- */

.hero {
  padding-top: 88px;
  padding-bottom: 40px;
  text-align: center;
}
.hero h1 {
  margin: 0 auto;
  max-width: 920px;
  font-size: clamp(44px, 7vw, 76px);
  line-height: 1.04;
}
.hero h1 em {
  color: var(--blue);
}
.hero .lede {
  margin: 26px auto 0;
  max-width: 640px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--muted);
}
.hero .install {
  margin: 40px auto 0;
  max-width: 640px;
}
.actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}
.scroll-hint {
  margin: 40px 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.section {
  padding-top: 96px;
  padding-bottom: 96px;
}
.section-band {
  background: var(--band);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.section-top {
  border-top: 1px solid var(--line);
}
.section h2 {
  margin: 0;
  font-size: clamp(32px, 4.4vw, 44px);
}
.section h2 + p,
.section .tag + h2 + p {
  margin-top: 22px;
}
.section p {
  margin: 18px 0 0;
}
.big {
  font-size: 21px;
}
.tag {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
}
.roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  padding-top: 24px;
  padding-bottom: 96px;
}
.roles h3 {
  margin: 0 0 8px;
  font-size: 24px;
}
.roles p {
  margin: 0;
  font-size: 18px;
  line-height: 1.55;
  color: var(--muted);
}
.roles > div {
  border-top: 2px solid var(--line);
  padding-top: 18px;
}
.roles .you {
  border-top-color: var(--blue);
}
.roles .play {
  border-top-color: var(--purple);
}
.roles .part {
  border-top-color: var(--amber);
}
.split {
  display: flex;
  gap: 56px;
  align-items: center;
}
.split > * {
  flex: 1;
  min-width: 0;
}
.split p {
  font-size: 20px;
  color: var(--muted);
}
.points {
  margin: 48px 0 0;
  display: grid;
  gap: 18px;
  font-size: 19px;
  line-height: 1.55;
}
.points dt {
  font-family: var(--mono);
  font-size: 13px;
}
.points dd {
  margin: 4px 0 0;
  color: var(--muted);
}
.aside-note {
  margin-top: 36px;
  border-left: 2px solid var(--line);
  padding-left: 18px;
  font-size: 19px;
  color: var(--muted);
}
.agents {
  margin-top: 28px;
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}
.agents th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
}
.agents th,
.agents td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.agents td:nth-child(2) {
  color: var(--muted);
}
.agents .yes {
  color: var(--green);
}
.limits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px 28px;
  padding-top: 40px;
  padding-bottom: 96px;
}
.limits h3 {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.limits p {
  margin: 8px 0 0;
  font-size: 18px;
  line-height: 1.55;
  color: var(--muted);
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px;
  color: var(--text);
}
a.card {
  background: var(--surface);
}
a.card:hover {
  text-decoration: none;
  border-color: var(--text);
}
.card .title {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
}
.card .text {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  color: var(--muted);
}

/* ---- the TUI figure: a still of the chat screen ---- */

.tui {
  width: 1040px;
  max-width: none;
  margin: 0 auto;
  background: #0b0d10;
  color: #d5d9de;
  font-family: var(--term);
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid #262b33;
  border-radius: 8px;
  overflow: hidden;
  text-align: left;
  color-scheme: dark;
}
.tui .bar {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #1e232a;
  color: #6b7480;
  font-size: 12px;
}
.tui .body {
  display: flex;
  height: 560px;
}
.tui .side {
  width: 236px;
  flex: none;
  border-right: 1px solid #1e232a;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
}
.tui .side .row {
  display: flex;
  gap: 8px;
  padding: 2px 12px;
}
.tui .side .row.agent {
  padding-left: 28px;
}
.tui .side .row.open {
  background: #12151a;
}
.tui .side .room {
  color: #e8eaed;
  font-weight: 700;
}
.tui .side .h {
  color: #6b7480;
  margin-left: 0;
}
.tui .side .r {
  margin-left: auto;
  color: #6b7480;
}
.tui .side .head {
  padding: 0 12px 6px;
  color: #6b7480;
  display: flex;
  justify-content: space-between;
}
.tui .side .files {
  margin-top: auto;
  padding: 10px 12px 0;
  border-top: 1px solid #1e232a;
  color: #6b7480;
}
.tui .main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.tui .log {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}
.tui .msg {
  display: flex;
  gap: 10px;
  padding: 6px 14px 6px 12px;
}
.tui .msg::before {
  content: "";
  width: 3px;
  flex: none;
  border-radius: 1px;
  background: var(--who, #5b636e);
}
.tui .msg.you {
  background: #13171c;
}
.tui .who {
  color: var(--who, #9aa3ae);
  font-weight: 700;
}
.tui .meta,
.tui .tool,
.tui .dim {
  color: #7d8692;
}
.tui .text {
  white-space: pre-line;
}
.tui .q {
  margin: 0 12px 8px;
  border: 1px solid #ff6ac1;
  border-radius: 6px;
  padding: 8px 12px;
}
.tui .act {
  padding: 1px 14px;
  display: flex;
  gap: 8px;
}
.tui .compose {
  margin: 6px 12px 4px;
  border: 1px solid #2a3038;
  border-radius: 6px;
  padding: 7px 12px;
  color: #e8eaed;
}
.tui .cursor {
  background: #5cc8ff;
}
.tui .where {
  padding: 0 14px 6px;
  color: #9aa3ae;
}
.tui .status {
  padding: 4px 14px 6px;
  border-top: 1px solid #1e232a;
  color: #6b7480;
  display: flex;
  gap: 12px;
}
.tui .status .end {
  margin-left: auto;
}
.tui .po {
  --who: #c792ea;
  color: #c792ea;
}
.tui .dev {
  --who: #ffb454;
  color: #ffb454;
}
.tui .rev {
  --who: #7fd99a;
  color: #7fd99a;
}
.tui .writer {
  color: #8fb3ff;
}
.tui .ask {
  color: #ff6ac1;
}
.tui .room-mark {
  color: #5cc8ff;
}
.tui .add {
  color: #7fd99a;
}
.tui .del {
  color: #ff7a7a;
}
.tui .idle {
  color: #6b7480;
}

/* ---- guide ---- */

.guide {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 56px;
  align-items: flex-start;
}
.toc {
  flex: 0 0 236px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 32px 0 48px;
  font-family: var(--mono);
  font-size: 11px;
}
.toc p {
  margin: 18px 0 6px 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.toc p:first-child {
  margin-top: 0;
}
.toc a {
  display: block;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 4px;
  line-height: 1.5;
}
.toc a:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.toc a[aria-current="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 2px 0 0 var(--blue);
}
.doc {
  flex: 1;
  min-width: 0;
  max-width: 760px;
  padding: 44px 0 96px;
}
.doc h1 {
  margin: 0;
  font-size: clamp(38px, 5vw, 52px);
}
.doc .lede {
  margin: 16px 0 0;
  font-size: 22px;
  color: var(--muted);
}
.doc h2 {
  margin: 72px 0 0;
  padding-top: 8px;
  font-size: 34px;
}
.doc h3 {
  margin: 40px 0 0;
  font-size: 24px;
}
.doc p,
.doc ul,
.doc ol {
  margin: 14px 0 0;
}
.doc li + li {
  margin-top: 6px;
}
.doc pre {
  margin-top: 16px;
}
.doc .install {
  margin-top: 16px;
}
.doc .install pre {
  margin-top: 0;
}
.step {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--muted);
  margin-right: 10px;
}
.note {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  background: var(--surface);
  padding: 14px 18px;
  font-size: 18px;
}
.note.warn {
  border-left-color: var(--pink);
}
.note .kicker {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--amber);
}
.note.warn .kicker {
  color: var(--pink);
}
.note p {
  margin: 4px 0 0;
}
.table-box {
  margin-top: 16px;
  overflow-x: auto;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
  line-height: 1.5;
}
.doc th,
.doc td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px 10px 0;
  border-bottom: 1px solid var(--line);
}
.doc th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.pager {
  margin-top: 64px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  font-family: var(--mono);
  font-size: 12px;
}

/* ---- 404 ---- */

.lost {
  padding: 120px 0;
  text-align: center;
}
.lost h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 64px);
}

/* ---- narrow screens ---- */

/* The TUI still is a fixed 1040px picture: shrink it to fit, like an image. */
@media (max-width: 1100px) {
  .tui {
    zoom: 0.84;
  }
}
@media (max-width: 900px) {
  .tui {
    zoom: 0.66;
  }
}
@media (max-width: 700px) {
  .tui {
    zoom: 0.5;
  }
}
@media (max-width: 520px) {
  .tui {
    zoom: 0.32;
  }
  .install .tabs {
    overflow-x: auto;
  }
  .install .tabs .soon {
    display: none;
  }
}

@media (max-width: 900px) {
  .roles,
  .limits,
  .cards {
    grid-template-columns: minmax(0, 1fr);
  }
  .split {
    flex-direction: column;
    align-items: stretch;
    gap: 28px;
  }
  .nav {
    order: 3;
    width: 100%;
    padding-bottom: 12px;
  }
  .guide {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .doc {
    width: 100%;
  }
  .toc {
    position: static;
    max-height: none;
    width: 100%;
    flex: none;
    padding-bottom: 0;
    columns: 2;
  }
  .toc p {
    break-after: avoid;
  }
}
@media (max-width: 520px) {
  body {
    font-size: 18px;
  }
  .nav-end {
    display: none;
  }
  .hero {
    padding-top: 56px;
  }
}
