/* ==========================================================================
   Design tokens
   Light: white and grays, black as the accent (dark overrides further
   down). Geist for text, Geist Mono for code and page content, Instrument
   Serif for big headings. Depth comes from hairlines and soft shadows.
   See DESIGN.md for the reasons behind these choices.
   ========================================================================== */
:root {
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;

  --bg: #fff;
  --bg-2: #fafafa;
  --surface: #fff;
  --surface-2: #f5f5f5;
  --surface-3: #ededed;
  --border: #ebebeb;
  --border-2: #dcdcdc;
  --text: #171717;
  --text-2: #5f5f5f;
  --text-3: #8f8f8f;
  --strong: #0a0a0a;
  --on-strong: #fff;
  --danger: #d4252f;
  --danger-soft: rgba(212, 37, 47, 0.06);
  --warn: #b7791f;
  --warn-soft: rgba(245, 180, 40, 0.09);
  --ok: #1f9d60;

  --gloss: linear-gradient(180deg, #fff, #fafafa);
  --gloss-strong: linear-gradient(180deg, #fff, #f2f2f2);
  --edge: inset 0 1px 0 #fff, 0 1px 2px rgba(0, 0, 0, 0.04);

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --pill: 999px;
  --container: 1120px;

  color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 0.5em; font-weight: 600; color: var(--strong); }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.4rem; letter-spacing: -0.02em; }
h3 { font-size: 1rem; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--strong); text-decoration-color: var(--border-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text-2); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--strong); outline-offset: 2px; }
::selection { background: rgba(0, 0, 0, 0.132); }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface-3); border: 1px solid var(--border); padding: 0.1em 0.4em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
svg { flex: none; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-2); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ==========================================================================
   Header & footer
   ========================================================================== */
.site-header { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, 0.8); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--strong); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--strong); color: var(--on-strong); display: inline-flex; align-items: center; justify-content: center; }
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -0.03em; }
/* Every header control is 34px tall so the row lines up. */
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; flex: none; }
.nav-link { display: inline-flex; align-items: center; height: 34px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; text-decoration: none; transition: color 0.15s, background 0.15s; }
.nav-link:hover { color: var(--strong); background: var(--surface-2); }
.nav-link[aria-current] { color: var(--strong); font-weight: 500; }
.nav-sep { width: 1px; height: 18px; margin: 0 8px; background: var(--border-2); }
.nav .btn-small { height: 34px; min-height: 34px; margin-left: 6px; padding: 0 14px; }
.account { position: relative; margin-left: 4px; }
.avatar { list-style: none; width: 34px; height: 34px; border-radius: var(--pill); background: var(--gloss-strong); border: 1px solid var(--border-2); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: color 0.15s, border-color 0.15s; }
.avatar::-webkit-details-marker { display: none; }
.avatar svg { width: 16px; height: 16px; }
.avatar:hover, .account[open] .avatar, .avatar.is-current { color: var(--strong); border-color: var(--text-3); }
.account-menu { left: auto; right: 0; top: calc(100% + 8px); width: 248px; animation: menu-in 0.14s ease-out; }
.account-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.account-who strong { font-size: 13.5px; font-weight: 500; color: var(--strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu .page-menu-item[aria-current] { background: var(--surface-3); }
.menu-small-only { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }

main { flex: 1; padding: 0 0 72px; }
main:has(.h) { padding-bottom: 0; }
main > .container > .alert:first-child { margin-top: 24px; }

.site-footer { border-top: 1px solid var(--border); }
.site-footer .container { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding-top: 28px; padding-bottom: 36px; font-size: 13.5px; color: var(--text-3); }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--strong); }
.site-footer .brand-name { color: var(--strong); font-size: 15px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  font: inherit; font-weight: 500; font-size: 14px; line-height: 1.2;
  color: var(--text);
  background: var(--gloss);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--edge);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { border-color: #bdbdbd; background: var(--gloss-strong); color: var(--strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.htmx-request { opacity: 0.45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: linear-gradient(180deg, #2e2e2e, #0a0a0a); border-color: #0a0a0a; color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 6px 18px -8px rgba(0, 0, 0, 0.45); }
.btn-primary:hover { background: #000; border-color: #000; color: #fff; }
.btn-dark { background: var(--surface-3); }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { background: var(--danger-soft); border-color: rgba(212, 37, 47, 0.3); color: var(--danger); box-shadow: none; }
.btn-danger:hover { background: rgba(212, 37, 47, 0.1); border-color: var(--danger); color: var(--danger); }
.btn-outline-light { background: none; }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-link { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: var(--text); font-size: inherit; text-decoration: underline; text-decoration-color: var(--border-2); text-underline-offset: 3px; }
.btn-link:hover { background: none; color: var(--strong); text-decoration-color: var(--text-2); }
.icon-btn { width: 38px; padding: 0; }

.disclosure { list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0; font-weight: 500; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.disclosure::-webkit-details-marker { display: none; }
.disclosure:hover { color: var(--strong); }
.disclosure svg { width: 14px; height: 14px; transition: transform 0.15s; }
details[open] > .disclosure svg { transform: rotate(180deg); }

/* ==========================================================================
   Surfaces, forms, pills
   ========================================================================== */
.card { background: var(--gloss), var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--edge); padding: 24px; margin-top: 16px; }
.card-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-header h2 { margin: 0; font-size: 1.1rem; }
.card.danger { border-color: rgba(212, 37, 47, 0.25); }
.panel { background: var(--gloss), var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: var(--pill); background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"] {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
}
input:focus { outline: none; border-color: var(--text-2); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.048); }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

.copy-field { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 4px 4px 4px 12px; }
.copy-field .value { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy-field .btn { flex: none; min-height: 30px; padding: 0 12px; font-size: 13px; }

/* ==========================================================================
   Alerts, badges, tooltips
   ========================================================================== */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface-2); margin-bottom: 16px; font-size: 14px; }
.alert p { margin: 0; }
.alert svg { width: 18px; height: 18px; margin-top: 2px; }
.alert-success { border-color: rgba(31, 157, 96, 0.3); }
.alert-success::before { content: ""; width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.alert-error { background: var(--danger-soft); border-color: rgba(212, 37, 47, 0.3); color: #a31b23; }
.alert-info, .alert-warn { background: var(--warn-soft); border-color: rgba(183, 121, 31, 0.28); }

.badge { display: inline-block; padding: 1px 9px; border-radius: var(--pill); font-size: 12px; font-weight: 500; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-2); }
.badge-success { color: var(--ok); }
.badge-accent { background: var(--strong); color: var(--on-strong); border-color: var(--strong); }

.tip-wrap { position: relative; }
.tip {
  display: none;
  position: absolute; z-index: 40; top: calc(100% + 8px); left: 0;
  width: 260px; max-width: 80vw;
  background: var(--surface-3); color: var(--text-2);
  border: 1px solid var(--border-2);
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.45; font-weight: 400;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.12);
}
.tip strong { display: block; margin-bottom: 2px; color: var(--strong); font-weight: 500; }
.tip .tip-action { margin-top: 6px; color: var(--text-3); }
.tip-right { left: auto; right: 0; }
.tip-up { top: auto; bottom: calc(100% + 8px); }
.tip-wrap:hover > .tip, .tip-wrap:focus-within > .tip { display: block; }

/* ==========================================================================
   Tables & lists
   ========================================================================== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child { text-align: right; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; }

.code-block { margin: 0; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 14px 16px; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; overflow-x: auto; white-space: pre; }
.code-block .comment { color: var(--text-3); }
.small-code { font-size: 12.5px; }

/* ==========================================================================
   Generic pages
   ========================================================================== */
.page-header { margin: 40px 0 8px; }
.page-header h1 { font-family: var(--font-display); font-weight: 400; font-size: 44px; letter-spacing: -0.01em; }
.page-header p { color: var(--text-2); margin: 0; }

.auth { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.auth h1 { font-family: var(--font-display); font-weight: 400; font-size: 40px; letter-spacing: -0.01em; }
.auth .subtitle { color: var(--text-2); margin-bottom: 24px; }
.auth .card { padding: 24px; text-align: left; }

.error-page { text-align: center; padding: 18vh 0 4rem; }
.error-page .code { font-family: var(--font-mono); font-size: 14px; color: var(--text-3); margin-bottom: 12px; background: none; border: 0; }
.error-page h1 { font-family: var(--font-display); font-weight: 400; font-size: 44px; letter-spacing: -0.01em; }

.upgrade-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-radius: var(--radius-sm); background: var(--gloss-strong); border: 1px solid var(--border-2); }
.upgrade-box strong, .upgrade-box span { display: block; }
.upgrade-box form { margin: 0; }

/* ==========================================================================
   Landing: one screen. The pitch and prices on the left, a diagram of a
   page being read over HTTP on the right.
   ========================================================================== */
.h {
  min-height: calc(100vh - 60px - 90px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); align-items: center; gap: 56px;
  padding: 32px 0;
}
.h-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
.h-tag { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: var(--pill); border: 1px solid var(--border-2); background: var(--gloss); box-shadow: var(--edge); font-size: 13px; color: var(--text-2); }
.h-spark { width: 12px; height: 12px; background: var(--strong); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: spark 3s ease-in-out infinite; }
@keyframes spark { 0%, 100% { transform: scale(0.8) rotate(0deg); } 50% { transform: scale(1.1) rotate(90deg); } }
.h h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(48px, 6.6vw, 84px); line-height: 0.98; letter-spacing: -0.02em; }
.h-soft { color: var(--text-3); font-style: italic; }
.h-lead { margin: 0; max-width: 470px; font-size: 17px; color: var(--text-2); }
.h-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.h-price { margin: 6px 0 0; width: 100%; max-width: 470px; border-top: 1px solid var(--border); }
.h-price > div { display: flex; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.h-price dt { width: 44px; flex: none; font-weight: 600; color: var(--strong); }
.h-price dd { margin: 0; color: var(--text-2); }
.h-price .h-cost { margin-left: auto; color: var(--strong); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

.h-art { position: relative; display: flex; flex-direction: column; gap: 14px; }
.h-art::before { content: ""; position: absolute; inset: -40px -20px; z-index: -1; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.05), transparent), radial-gradient(circle, #d6d6d6 1px, transparent 1.5px) 0 0 / 18px 18px; mask-image: radial-gradient(closest-side, #000 40%, transparent); -webkit-mask-image: radial-gradient(closest-side, #000 40%, transparent); }

/* The diagram */
.flow { width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
/* The source page: a small document with Text and JSON tabs. */
.src { height: 100%; margin: 8px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.25); overflow: hidden; font-family: var(--font-sans); }
.src-bar { display: flex; align-items: center; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); }
.src-tab { min-height: 24px; padding: 0 9px; border: 0; border-radius: 6px; background: none; color: var(--text-3); font: 500 11.5px var(--font-sans); }
.src-tab:hover { color: var(--strong); }
.src-tab.is-active { background: var(--surface-3); color: var(--strong); }
.src-file { margin-left: auto; padding-right: 4px; font-family: var(--font-mono); font-size: 10px; color: var(--text-3); }
.src-text { flex: 1; margin: 0; padding: 12px 14px; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; color: var(--text); white-space: pre; overflow: hidden; animation: fade-up 0.35s ease-out; }
.f-link { fill: none; stroke: #b5b5b5; stroke-width: 1.5; stroke-dasharray: 3 5; animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -16; } }
.f-dot { fill: var(--strong); }
.flow foreignObject { overflow: visible; }
.f-node { fill: #fff; stroke: var(--border-2); stroke-width: 1.2; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.06)); }
.f-icon svg { width: 20px; height: 20px; color: var(--strong); }
.f-name { font-size: 14px; font-weight: 600; fill: var(--strong); }
.f-call { font-family: var(--font-mono); font-size: 11px; fill: var(--text-3); }

/* The little terminal under the diagram */
.h-term { margin-left: 22%; padding: 12px 16px; border: 1px solid var(--border-2); border-radius: var(--radius); background: #0a0a0a; color: #ededed; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7; box-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.35); min-height: 84px; overflow: hidden; }
.t-line { white-space: pre; min-height: 1.7em; overflow: hidden; text-overflow: ellipsis; }
.t-cmd { color: #fff; }
.t-out { color: #a1a1a1; }
.t-line.is-typing::after { content: ""; display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; background: #fff; animation: blink 1s steps(1) infinite; }
.h-term.is-running .t-line:not(.is-shown) { visibility: hidden; }
.t-out.is-shown { animation: fade-up 0.25s ease-out; }
@keyframes fade-up { from { opacity: 0; transform: translateY(3px); } }
@keyframes blink { 50% { opacity: 0; } }

/* ==========================================================================
   Editor: the text first, everything else folded away.
   ========================================================================== */
.ed { padding-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.ed-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.ed-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 auto; }
.ed-actions { display: flex; align-items: center; gap: 8px; }
.ed-actions form { margin: 0; }

.page-switcher { position: relative; min-width: 0; }
.page-switcher > summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 8px 4px 2px; border-radius: var(--radius-sm); cursor: pointer; }
.page-switcher > summary::-webkit-details-marker { display: none; }
.page-switcher > summary:hover { background: var(--surface-2); }
.page-switcher h1 { margin: 0; font-size: 20px; letter-spacing: -0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-switcher > summary svg { width: 16px; height: 16px; color: var(--text-3); transition: transform 0.15s; }
.page-switcher[open] > summary svg { transform: rotate(180deg); }
.page-menu { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 300px; max-width: calc(100vw - 32px); padding: 6px; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.14); }
.page-menu nav { display: flex; flex-direction: column; max-height: min(360px, 55vh); overflow-y: auto; }
.page-menu form { margin: 0; }
.page-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.page-menu-item:hover { background: var(--surface-3); }
.page-menu-item svg { width: 15px; height: 15px; color: var(--text-3); }
.page-menu-icon { display: inline-flex; flex: none; }
.page-menu-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-menu-item.is-current { background: var(--surface-3); }
.page-menu-item.is-current svg:last-child { color: var(--strong); }
.page-menu-new { color: var(--text-2); }
.page-menu-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.page-menu-count { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; padding: 2px 10px; font-size: 12.5px; color: var(--text-3); }
.page-menu-count form { margin: 0; }

.rename { position: relative; }
.rename-btn { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px; color: var(--text-3); cursor: pointer; }
.rename-btn::-webkit-details-marker { display: none; }
.rename-btn:hover, .rename[open] .rename-btn { background: var(--surface-2); color: var(--strong); }
.rename-btn svg { width: 15px; height: 15px; }
.rename-form { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 320px; max-width: 86vw; display: flex; flex-direction: column; gap: 8px; padding: 14px; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.14); }
.rename-form label { font-weight: 500; font-size: 13px; color: var(--text-2); }
.rename-form .row { flex-wrap: nowrap; }
.rename-form .hint { margin: 0; }

.status { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; font-size: 13px; color: var(--text-3); white-space: nowrap; }
.status svg { width: 14px; height: 14px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--strong); box-shadow: 0 0 8px rgba(0, 0, 0, 0.36); }
.status [data-when="dirty"] { color: var(--text); }
.status [data-when] { display: none; }
.status[data-state="saved"] [data-when="saved"], .status[data-state="dirty"] [data-when="dirty"] { display: inline-flex; align-items: center; gap: 6px; }

.address { max-width: 100%; }
.address-pill { display: flex; align-items: center; gap: 4px; height: 38px; padding: 0 4px 0 12px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--bg); max-width: 360px; }
.address-pill .value { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.address-pill .btn { flex: none; min-height: 28px; padding: 0 8px; font-size: 12.5px; border-color: transparent; background: none; box-shadow: none; color: var(--text-2); }
.address-pill .btn:hover { background: var(--surface-3); color: var(--strong); }
.address-pill .btn svg { width: 14px; height: 14px; }

.privacy-btn svg { width: 16px; height: 16px; }
/* Filled when public. Its own shadow: the default white top highlight would
   show as a bright line on the dark fill. */
.privacy-btn.is-public { background: var(--strong); border-color: var(--strong); color: var(--on-strong); box-shadow: none; }

.readonly-note p { margin: 2px 0 10px; color: var(--text-2); }
.readonly-note form { margin: 0; }
.conflict { flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0; }
.conflict-text { flex: 1 1 280px; display: flex; gap: 12px; align-items: flex-start; }
.conflict-text strong { display: block; font-weight: 500; }
.conflict-text span { color: var(--text-2); font-size: 13.5px; }
.conflict-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conflict-preview { flex: 1 1 100%; }
.conflict-latest { margin: 4px 0 0; max-height: 300px; overflow: auto; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 12px 14px; font-family: var(--font-mono); font-size: 13px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: break-word; }

.editor-card { background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-lg); box-shadow: var(--edge), 0 30px 80px -50px rgba(0, 0, 0, 0.09); overflow: hidden; transition: border-color 0.15s; }
.editor-card:focus-within { border-color: #bdbdbd; }
.editor-card form { margin: 0; }
.editor-toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--gloss); flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; flex: 0 1 300px; min-width: 180px; height: 32px; padding: 0 10px; border-radius: 7px; color: var(--text-3); }
.search:focus-within { background: var(--bg); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }
.search svg { width: 15px; height: 15px; }
.search input { flex: 1; min-width: 0; min-height: 0; height: 30px; border: 0; padding: 0; background: transparent; font-size: 13.5px; }
.search input:focus { box-shadow: none; }
.search-count { font-size: 12px; white-space: nowrap; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tool-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--text-3); }
.tool-btn:hover { background: var(--surface-3); color: var(--strong); }
.tool-btn svg { width: 15px; height: 15px; }
.tool-btn.tool-text { padding: 0 10px; font-size: 13px; font-weight: 500; }

/* The text area: it scrolls inside a tall, resizable box, with a
   color-coded copy kept in sync underneath when JavaScript runs. */
.editor-surface { position: relative; height: max(380px, calc(100vh - 280px)); min-height: 200px; resize: vertical; overflow: hidden; font-family: var(--font-mono); font-size: 14.5px; line-height: 1.75; }
.editor-surface textarea, .editor-highlight { box-sizing: border-box; margin: 0; padding: 22px 28px; border: 0; font-family: inherit; font-size: inherit; line-height: inherit; letter-spacing: inherit; white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word; tab-size: 2; scrollbar-gutter: stable; }
.editor-surface textarea { display: block; width: 100%; height: 100%; resize: none; overflow: auto; background: transparent; color: var(--text); }
.editor-surface textarea::placeholder { color: var(--text-3); }
.editor-surface textarea:focus, .editor-surface textarea:focus-visible { outline: none; }
.editor-surface textarea[readonly] { cursor: default; }
.editor-highlight { display: none; position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--text); }
.editor-surface.is-enhanced .editor-highlight { display: block; }
.editor-surface.is-enhanced textarea { position: relative; z-index: 1; color: transparent; caret-color: var(--strong); }
.editor-surface.is-enhanced textarea::selection { background: rgba(0, 0, 0, 0.12); color: transparent; }
.editor-highlight mark { background: rgba(0, 0, 0, 0.108); color: inherit; border-radius: 3px; }
.editor-highlight mark.current { background: var(--strong); color: var(--on-strong); box-shadow: 0 0 0 2px var(--strong); }
.editor-highlight mark.current span { color: var(--on-strong); }
.tok-key { color: #000; }
.tok-str { color: #6b6b6b; }
.tok-num { color: #3d3d3d; }
.tok-word { color: #3d3d3d; font-style: italic; }
.tok-punc { color: #a8a8a8; }

.editor-warning { display: flex; gap: 10px; align-items: center; margin: 0; padding: 10px 16px; border-top: 1px solid rgba(183, 121, 31, 0.25); background: var(--warn-soft); font-size: 13px; }
.editor-warning svg { width: 15px; height: 15px; color: var(--warn); }
.editor-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 44px; padding: 4px 12px; border-top: 1px solid var(--border); }
.editor-keys { margin: 0; font-size: 12px; color: var(--text-3); }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text-2); }
.room-note { font-size: 12.5px; }
.room-note form { margin: 0; }
.switch-btn { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border: 0; border-radius: 7px; background: none; color: var(--text-3); font-size: 13px; }
.switch-btn:hover { color: var(--strong); background: var(--surface-3); }
.switch { width: 28px; height: 16px; border-radius: var(--pill); background: var(--border-2); display: inline-flex; align-items: center; padding: 2px; transition: background 0.15s; }
.switch::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform 0.15s, background 0.15s; }
.switch-btn[aria-pressed="true"] .switch { background: var(--strong); }
.switch-btn[aria-pressed="true"] .switch::after { transform: translateX(12px); background: var(--on-strong); }
.meter-btn { display: inline-flex; align-items: center; height: 32px; padding: 0 4px; background: none; border: 0; cursor: default; }
.meter { width: 96px; height: 4px; border-radius: var(--pill); background: var(--border-2); display: block; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: var(--pill); background: var(--text-2); }
.meter-fill.high { background: var(--danger); }

.ed-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.drawer { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2); }
.drawer > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 46px; padding: 0 16px; font-size: 14px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.drawer > summary::-webkit-details-marker { display: none; }
.drawer > summary:hover { color: var(--strong); }
.drawer > summary svg { width: 15px; height: 15px; transition: transform 0.15s; }
.drawer[open] > summary { color: var(--strong); border-bottom: 1px solid var(--border); }
.drawer[open] > summary svg { transform: rotate(180deg); }
.drawer-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.option { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin: 0; }
.option > strong { font-weight: 500; font-size: 14px; color: var(--strong); }
.option > p { margin: 0; font-size: 13px; color: var(--text-2); }
.option .copy-field, .option .code-block { align-self: stretch; }
.option form { margin: 0; }
.option-rule { height: 1px; background: var(--border); }
.inline-details { align-self: stretch; }
.prompt-text { margin: 4px 0 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; color: var(--text-2); white-space: pre-wrap; overflow-wrap: break-word; }

/* ==========================================================================
   llms.txt in a browser: a human view and a machine view
   ========================================================================== */
html:not([data-mode="machine"]) [data-machine-only] { display: none; }
html[data-mode="machine"] [data-human-only],
html[data-mode="machine"] .site-header,
html[data-mode="machine"] .site-footer { display: none; }
html[data-mode="machine"] main { padding: 0; }

.guide-hero { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: 64px 0 40px; max-width: 760px; }
.guide-hero h1 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(40px, 5.6vw, 64px); line-height: 1; letter-spacing: -0.02em; }
.guide-hero .lead { margin: 0; font-size: 17px; color: var(--text-2); }
.guide { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 48px; align-items: start; padding-bottom: 96px; }
.guide-toc { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 1px; font-size: 13.5px; }
.guide-toc-title { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 8px; }
.guide-toc a { padding: 5px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; }
.guide-toc a:hover { background: var(--surface-2); color: var(--strong); }
.prose { max-width: 820px; font-size: 15.5px; line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 24px; margin: 56px 0 14px; padding-top: 24px; border-top: 1px solid var(--border); scroll-margin-top: 84px; }
.prose h2:first-of-type { margin-top: 32px; }
.prose h3 { font-size: 17px; margin: 28px 0 10px; scroll-margin-top: 84px; }
.prose p, .prose ul, .prose ol { margin: 0 0 16px; color: var(--text-2); }
.prose ul, .prose ol { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose strong { color: var(--text); font-weight: 500; }
.prose blockquote { margin: 0 0 24px; padding: 16px 20px; background: var(--gloss), var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius); }
.prose blockquote p { margin: 0; color: var(--text); }
.prose blockquote p + p { margin-top: 8px; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 500; }
.prose .code-wrap { position: relative; margin: 0 0 20px; }
.prose pre { margin: 0 0 20px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 16px 18px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.7; }
.prose .code-wrap pre { margin: 0; padding-right: 80px; }
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
.code-copy { position: absolute; top: 8px; right: 8px; min-height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.code-copy:hover { color: var(--strong); }

.machine { min-height: 100vh; color: var(--text); font-family: var(--font-mono); padding: 28px 0 120px; }
.machine-bar { max-width: 960px; margin: 0 auto; padding: 0 24px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.machine-title { font-size: 14px; color: var(--strong); }
.machine-meta { font-size: 12px; color: var(--text-3); }
.machine-btn { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border-2); background: none; color: var(--text-2); font: 500 12px var(--font-mono); text-decoration: none; }
.machine-btn:hover { color: var(--strong); border-color: #bdbdbd; }
.machine-text { max-width: 960px; margin: 0 auto; padding: 22px 24px 0; font: 13.5px/1.7 var(--font-mono); white-space: pre-wrap; overflow-wrap: break-word; color: var(--text-2); }

.mode-toggle { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--pill); background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border-2); box-shadow: 0 12px 40px -10px rgba(0, 0, 0, 0.14); }
.mode-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 14px; border: 0; border-radius: var(--pill); background: transparent; color: var(--text-3); font: 500 13px var(--font-sans); }
.mode-btn:hover { color: var(--strong); }
.mode-btn[aria-pressed="true"] { background: var(--surface-3); color: var(--strong); }
.mode-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); }
.mode-btn[aria-pressed="true"] .mode-dot { background: var(--strong); box-shadow: 0 0 8px rgba(0, 0, 0, 0.42); }

/* ==========================================================================
   Dark theme: chosen with the header toggle (html[data-theme="dark"]).
   Light is the default. Tokens first, then the few hard-coded colors.
   ========================================================================== */
:root[data-theme="dark"] {
  --bg: #000;
  --bg-2: #0a0a0a;
  --surface: #0a0a0a;
  --surface-2: #111;
  --surface-3: #191919;
  --border: #1f1f1f;
  --border-2: #2e2e2e;
  --text: #ededed;
  --text-2: #a1a1a1;
  --text-3: #6f6f6f;
  --strong: #fff;
  --on-strong: #000;
  --danger: #ff6166;
  --danger-soft: rgba(255, 97, 102, 0.08);
  --warn: #f5c451;
  --warn-soft: rgba(245, 196, 81, 0.07);
  --ok: #3ecf8e;
  --gloss: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012));
  --gloss-strong: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}
[data-theme="dark"] ::selection { background: rgba(255, 255, 255, 0.22); }
[data-theme="dark"] .site-header { background: rgba(0, 0, 0, 0.7); }
[data-theme="dark"] .btn:hover, [data-theme="dark"] .editor-card:focus-within, [data-theme="dark"] .machine-btn:hover { border-color: #444; }
[data-theme="dark"] .btn-primary { background: linear-gradient(180deg, #fff, #e4e4e4); border-color: #fff; color: #000; box-shadow: 0 8px 24px -10px rgba(255, 255, 255, 0.3); }
[data-theme="dark"] .btn-primary:hover { background: #fff; border-color: #fff; color: #000; }
[data-theme="dark"] .alert-error { color: #ffc7c9; border-color: rgba(255, 97, 102, 0.35); }
[data-theme="dark"] .editor-highlight mark { background: rgba(255, 255, 255, 0.18); }
[data-theme="dark"] .editor-surface.is-enhanced textarea::selection { background: rgba(255, 255, 255, 0.2); }
[data-theme="dark"] .tok-key { color: #fff; }
[data-theme="dark"] .tok-str { color: #a1a1a1; }
[data-theme="dark"] .tok-num, [data-theme="dark"] .tok-word { color: #d4d4d4; }
[data-theme="dark"] .tok-punc { color: #5c5c5c; }
[data-theme="dark"] .switch::after { background: #a1a1a1; }
[data-theme="dark"] .switch-btn[aria-pressed="true"] .switch::after { background: #000; }
[data-theme="dark"] .mode-toggle { background: rgba(20, 20, 20, 0.85); }
[data-theme="dark"] .status-dot, [data-theme="dark"] .mode-btn[aria-pressed="true"] .mode-dot { box-shadow: 0 0 8px rgba(255, 255, 255, 0.6); }
[data-theme="dark"] .h-art::before { background: radial-gradient(closest-side, rgba(255, 255, 255, 0.07), transparent), radial-gradient(circle, #262626 1px, transparent 1.5px) 0 0 / 18px 18px; }
[data-theme="dark"] .f-node { fill: #0a0a0a; }
[data-theme="dark"] .f-link { stroke: #4a4a4a; }
[data-theme="dark"] .h-term { background: #050505; }

/* The theme toggle in the header shows the icon of the other theme. */
.theme-btn { width: 34px; height: 34px; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; transition: color 0.15s, background 0.15s; }
.theme-btn:hover { color: var(--strong); background: var(--surface-2); }
.theme-btn svg { width: 17px; height: 17px; }
.theme-btn span { display: inline-flex; }
.theme-btn .to-light, [data-theme="dark"] .theme-btn .to-dark { display: none; }
[data-theme="dark"] .theme-btn .to-light { display: inline-flex; }

/* ==========================================================================
   Motion & small screens
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .h-spark, .f-link, .src-text, .t-line.is-typing::after, .account-menu { animation: none; }
  .f-dot { display: none; }
}
@media (max-width: 860px) {
  .guide { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .guide-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .guide-toc-title { width: 100%; }
  .h { grid-template-columns: minmax(0, 1fr); gap: 40px; min-height: 0; padding-top: 40px; }
  .h-term { margin-left: 0; }
}
@media (max-width: 640px) {
  .site-header .container { height: 56px; gap: 6px; }
  .nav-extra, .nav-signin { display: none; }
  .menu-small-only { display: flex; }
  .nav .btn-small { margin-left: 4px; }
  .card, .panel { padding: 18px; }
  .h-lead { font-size: 16px; }
  .ed-actions { width: 100%; }
  .ed-actions .address { flex: 1; min-width: 0; }
  .address-pill { max-width: none; }
  .editor-surface textarea, .editor-highlight { padding: 16px; }
  .editor-surface { height: max(320px, calc(100vh - 300px)); }
  .editor-keys { display: none; }
}
