:root {
  color-scheme: light dark;
  --bg: #fbfaf8; --fg: #1d1c1a; --muted: #6e6b64; --line: #e3e0d9; --soft: #f2f0eb;
  --accent: #2f5fd0; --on-accent: #fff; --mark: #e8a600; --danger: #b3261e;
  --bar: 44px; --radius: 6px;
  --mono: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  /* The chevron of a menu, in --muted and in --on-accent. */
  --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%236e6b64' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); --caret-on: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191918; --fg: #e8e6e1; --muted: #9a968d; --line: #34332f; --soft: #242422;
    --accent: #8aa8f0; --on-accent: #111; --danger: #f28b82;
    --caret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%239a968d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); --caret-on: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%23111' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
* { box-sizing: border-box; }
/* Flex and grid rules below would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: inherit; }
h1 { font-size: 18px; margin: 0 0 16px; }
small, .muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.quiet { background: none; border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--fg); }
input, textarea, select { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px 8px; min-width: 0; }
input, textarea { width: 100%; }
textarea { display: block; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; }
.error { color: var(--danger); margin: 0; }

.bar { display: flex; align-items: center; gap: 8px; height: var(--bar); padding: 0 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.bar h1 { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home { color: var(--muted); font-weight: 600; text-decoration: none; }
.home:hover { color: var(--fg); }
.home::after { content: "/"; margin-left: 8px; color: var(--line); }
.pill { border-radius: 999px; border-color: transparent; background: var(--accent); color: var(--on-accent); font-size: 12px; padding: 2px 10px; }
#rev { max-width: 30ch; padding: 3px 6px; border-color: transparent; background: none; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rev:hover { color: var(--fg); }
/* What drops from a bar button (the version menu, the share popover, the page menu) is a popover
   under its button with the button's right edge, at least 8px from the left. Without anchor
   positioning it hangs under the bar at the right. --wide is its width. */
#rev { anchor-name: --rev; }
#share { anchor-name: --share; }
#more { anchor-name: --more; }
#versions, #sharing, #pagemenu { position: fixed; inset: auto; top: calc(var(--bar) - 5px); right: 8px; margin: 0; width: var(--wide); max-height: calc(100dvh - var(--bar) - 8px); overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); box-shadow: 0 8px 32px rgb(0 0 0 / .2); }
@supports (top: anchor(bottom)) {
  #versions, #sharing, #pagemenu { top: calc(anchor(bottom) + 4px); right: auto; left: max(8px, calc(anchor(right) - var(--wide))); }
}
#versions { --wide: min(340px, calc(100vw - 16px)); position-anchor: --rev; max-height: 60vh; }
#sharing { --wide: min(420px, calc(100vw - 16px)); position-anchor: --share; }
#pagemenu { --wide: 220px; position-anchor: --more; }
#versions button, #pagemenu button { display: block; width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius); background: none; text-align: left; font-size: 12px; color: var(--muted); }
#versions button:hover, #pagemenu button:hover { background: var(--soft); }
#versions [aria-current=true] { color: var(--fg); }
#versions b { color: var(--fg); font-weight: 600; }
#pagemenu button { font-size: inherit; color: var(--fg); }
#pagemenu button.danger { color: var(--danger); }
#pagemenu small { display: block; }
#versions small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon { display: inline-flex; align-items: center; gap: 4px; padding: 5px; border-color: transparent; background: none; color: var(--muted); }
.icon:hover { color: var(--fg); }
.icon svg { flex-shrink: 0; }
.icon span { font-size: 12px; line-height: 1; }
.icon span:empty { display: none; }
.icon[aria-pressed=true] { background: var(--soft); border-color: var(--line); color: var(--fg); }

.page { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.pages { list-style: none; padding: 0; margin: 0; }
.pages a { display: flex; gap: 12px; align-items: baseline; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.pages a:hover { background: var(--soft); }
.pages b { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pages small, .pages time, .who, code { font: var(--mono); }
.pages time { color: var(--muted); min-width: 3ch; text-align: right; }
.find { margin-bottom: 12px; }
.more { display: flex; justify-content: space-between; padding: 12px 4px; }
.more a:last-child { margin-left: auto; }
code { background: var(--soft); border-radius: 3px; padding: 1px 4px; }
.mint, .minted, .everywhere { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
:is(.mint, .everywhere) label { display: inline-flex; gap: 6px; align-items: center; }
:is(.mint, .everywhere) input[type=radio], :is(.mint, .everywhere) input[type=checkbox] { width: auto; }
.everywhere { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.everywhere p { margin: 0; }
.everywhere input[type=checkbox] { flex: none; }
.choices { display: flex; flex-direction: column; gap: 4px; padding-left: 20px; max-height: 12em; overflow-y: auto; }
.minted { padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius); }
.minted p { margin: 0; }
.agents, .agents ul { list-style: none; padding: 0; margin: 0; }
.agents ul { padding-left: 20px; }
.agents .agent { display: flex; gap: 12px; align-items: baseline; padding: 6px 4px; border-top: 1px solid var(--line); }
.agents .agent small:first-of-type { flex: 1; min-width: 0; }
.login { max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.for-agents { padding: 10px 12px; background: var(--soft); border-radius: var(--radius); font: var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.login .users { display: flex; flex-wrap: wrap; gap: 6px; }

body.viewer { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.split { flex: 1; display: flex; min-height: 0; }
#frame { flex: 1; min-width: 0; border: 0; background: white; transition: opacity .15s; }
#frame.loading { opacity: .5; }
aside { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
[data-side=closed] aside { display: none; }
.head { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; width: 100%; height: 40px; padding: 0 12px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; font-weight: 600; }
.head::after { content: "›"; color: var(--muted); font-size: 18px; font-weight: 400; }
[data-pending] .head { color: var(--accent); }
[data-pending] #toggle { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior-y: contain; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

.composer { display: flex; flex-direction: column; gap: 6px; }
.composer .row { justify-content: flex-end; }
.hint { margin-right: auto; }
.quote { display: flex; align-items: flex-start; gap: 4px; }
blockquote, .anchor { flex: 1; margin: 0; padding: 1px 8px; border-left: 3px solid var(--mark); color: var(--muted); font-size: 13px; white-space: pre-wrap; max-height: 4.4em; overflow: hidden; }
.anchor { display: block; width: 100%; text-align: left; background: none; border-width: 0 0 0 3px; border-radius: 0; cursor: pointer; }
.anchor:hover { color: var(--fg); border-left-color: var(--mark); }
.anchor.outdated, .anchor.outdated:hover { border-left-color: var(--line); text-decoration: line-through; text-decoration-color: var(--muted); }
.thread { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.thread.focused { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.thread > summary { display: flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.thread > summary::before { content: "▸"; }
.thread[open] > summary::before { content: "▾"; }
.gist { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--fg); }
.thread[open] .gist { visibility: hidden; }
.thread > div { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.thread > .reply { margin-top: 8px; }
.order { display: flex; align-self: flex-end; gap: 2px; margin-bottom: -6px; }
.order button { padding: 0 8px; border-color: transparent; background: none; color: var(--muted); font-size: 12px; }
.order button:hover { color: var(--fg); }
.order button[aria-pressed=true] { background: var(--soft); border-color: var(--line); color: var(--fg); }
.thread p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.who.agent, .mention, .body a { color: var(--accent); }
.mention { font-weight: 600; }
.body > * { margin: 4px 0 0; overflow-wrap: anywhere; }
.body li, .body p { white-space: pre-wrap; }
.body ul, .body ol { padding-left: 20px; }
.body pre { padding: 6px 8px; overflow-x: auto; background: var(--soft); border-radius: var(--radius); font: var(--mono); }
.body pre code { padding: 0; }
.body blockquote { flex: none; max-height: none; border-left-color: var(--line); }
.comment .react { margin-left: 4px; padding: 0 4px; border-color: transparent; background: none; color: var(--muted); font-size: 13px; line-height: 1; }
.comment .react:hover { color: var(--fg); }
/* Where there's a pointer, the add button shows on the comment it's for. */
@media (hover: hover) { .comment:not(:hover, :focus-within) .react { opacity: 0; } }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { padding: 0 7px; border-radius: 999px; font-size: 12px; line-height: 20px; }
.chip[aria-pressed=true] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.chip:disabled { cursor: default; color: inherit; }
.seen { display: block; margin-top: 4px; font-size: 11px; opacity: .7; }
.listening { font-size: 12px; opacity: .8; }
#emojis { position: fixed; inset: auto; margin: 0; padding: 4px; display: none; grid-template-columns: repeat(4, 36px); gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); box-shadow: 0 8px 32px rgb(0 0 0 / .2); }
#emojis:popover-open { display: grid; }
#emojis button { height: 36px; padding: 0; border: 0; background: none; font-size: 20px; }
#emojis button:hover { background: var(--soft); }
.tag { align-self: flex-start; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.reply { display: flex; flex-wrap: wrap; gap: 6px; }
.reply input { flex: 1; width: auto; min-width: 8em; }
.reply .error { flex-basis: 100%; }
.reopen { margin-top: 4px; }
.bubble { position: fixed; z-index: 2; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.marker { position: fixed; z-index: 1; display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 5px; border-color: var(--line); border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 11px; box-shadow: 0 1px 4px rgb(0 0 0 / .12); }
.marker:hover { color: var(--fg); border-color: var(--mark); }
.marker svg { width: 13px; height: 13px; }
.suggest { position: fixed; z-index: 2; list-style: none; margin: 0; padding: 4px; max-height: 16em; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 16px rgb(0 0 0 / .15); }
.suggest li { padding: 4px 8px; border-radius: 4px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li.chosen { background: var(--soft); }
.suggest small { font: var(--mono); color: var(--muted); }
summary { color: var(--muted); cursor: pointer; }
#resolved > div { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
details .thread { opacity: .75; }

dialog { width: min(420px, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); box-shadow: 0 8px 32px rgb(0 0 0 / .2); }
dialog::backdrop { background: rgb(0 0 0 / .3); }
dialog h2 { font-size: 15px; margin: 0 0 12px; }
.keys { border-collapse: collapse; font-size: 13px; }
.keys td { padding: 4px 12px 4px 0; vertical-align: top; }
kbd { padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--soft); font: var(--mono); }
dialog form, dialog label { display: flex; gap: 8px; align-items: center; }
dialog label { justify-content: space-between; margin-bottom: 8px; }
/* The share dialog keeps one grid: every row is one line on one baseline, and the role menus'
   carets, Copy link and the add button end at the same right edge. */
#sharing { padding: 20px; border-radius: 10px; }
/* The last row's own padding stands in for some of the dialog's. */
#sharing:has(.also[hidden]) { padding-bottom: 14px; }
#sharing .top { margin-bottom: 12px; }
#sharing h2 { flex: 1; margin: 0; font-size: 15px; }
#copy { display: inline-flex; align-items: center; gap: 6px; padding-right: 0; }
#add { display: flex; gap: 8px; align-items: stretch; }
#add input { padding: 5px 10px; }
/* The role and its button wait for a name. */
#add:has(input:placeholder-shown) .grant { display: none; }
/* One button in two parts: the first adds with the role it names, the second picks the role. */
.grant { display: flex; flex: none; }
.grant button { border-radius: var(--radius) 0 0 var(--radius); }
.grant select { appearance: none; width: 26px; padding: 0; border-color: var(--accent); border-left-color: color-mix(in srgb, var(--on-accent) 40%, var(--accent)); border-radius: 0 var(--radius) var(--radius) 0; background: var(--accent) var(--caret-on) center / 10px no-repeat; color: transparent; cursor: pointer; }
.grant option { background: Canvas; color: CanvasText; }
#sharing .error { margin-top: 8px; }
/* A change in flight redraws the rows, so they take no second one until it lands. */
#sharing[aria-busy=true] :is(.access, .also, #add) { pointer-events: none; }
.access { list-style: none; padding: 0; margin: 6px 0 0; }
.access li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; }
.party { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
.party > small { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.role { flex: none; padding: 2px 14px 2px 6px; border: 1px solid transparent; color: var(--muted); line-height: inherit; }
/* A reader has no carets, so the roles end at the edge themselves. */
#sharing:not(.owns) .role { padding-right: 0; }
/* A role menu is a native select, drawn as text and a caret until it is pointed at or focused. */
select.role { appearance: none; border-radius: var(--radius); background: transparent var(--caret) right -2px center / 10px no-repeat; text-align: right; cursor: pointer; }
select.role:hover, select.role:focus-visible { border-color: var(--line); color: var(--fg); }
.also { margin: 6px 0 0; font-size: 13px; }
.also .link { margin-left: 6px; font-size: inherit; }
dialog .row + .row, dialog form + .row { margin-top: 12px; }
.end { justify-content: flex-end; }
.finder { width: min(560px, calc(100vw - 32px)); margin-top: 12vh; padding: 8px; }
.finder ul { list-style: none; margin: 8px 0 0; padding: 0; }
.finder li { display: flex; gap: 12px; align-items: baseline; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.finder li.chosen, .finder li:hover { background: var(--soft); }
.finder b { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finder small, .finder time { font: var(--mono); color: var(--muted); }

/* Wide enough that a centered page leaves the panel a margin: overlay it, so opening it never reflows the page. */
@media (min-width: 1440px) {
  .split { position: relative; }
  aside { position: absolute; z-index: 1; top: 0; right: 0; bottom: 0; box-shadow: -4px 0 24px rgb(0 0 0 / .12); }
}

@media (max-width: 720px) {
  /* 16px keeps iOS from zooming into a focused field. */
  input, textarea, select, .access { font-size: 16px; }
  /* An email goes under its name, and the role stays on the name's line. */
  .party { flex-direction: column; align-items: start; gap: 0; }
  /* A sheet under the bar, like the comments panel: the bottom is where the keyboard comes up. */
  #sharing { top: var(--bar); left: 0; right: 0; --wide: auto; border-width: 0 0 1px; border-radius: 0 0 12px 12px; box-shadow: 0 4px 24px rgb(0 0 0 / .12); }
  .bar { padding: 0 8px; }
  #rev { max-width: 9em; }
  .hint { display: none !important; }
  /* Under the bar, so the OS selection menu and search sheet at the bottom never cover it, and
     ending above the keyboard (--keyboard), with the composer at its top. */
  aside {
    position: fixed; z-index: 1; left: 0; right: 0; top: var(--bar); bottom: max(var(--keyboard, 0px), 28dvh); width: auto;
    border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px; box-shadow: 0 4px 24px rgb(0 0 0 / .12);
  }
  .head::after { content: "×"; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.expires { background: var(--soft); color: var(--muted); }
.expires.soon { background: var(--mark); color: #1d1c1a; }
.expires[aria-disabled=true] { cursor: default; }
.banner, .note { display: flex; align-items: center; gap: 12px; margin: 0; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.banner { background: var(--soft); }
.banner span, .note { color: var(--muted); }
.banner span { flex: 1; }
body.ended #frame { opacity: .6; }
/* An owner who deletes a live page keeps reading it, with nothing left to write with. */
body.ended :is(#new, .reply, .react, .reopen, #share, #more, #expires) { display: none; }
.gone h1 { margin-top: 24px; }
button.danger { color: var(--danger); }
button.link { padding: 0; text-decoration: underline; font-size: 12px; }
.deleted { margin-top: 24px; }
.deleted summary { color: var(--muted); cursor: pointer; padding: 4px; }
.deleted li { display: flex; align-items: center; gap: 8px; }
.deleted li a { flex: 1; min-width: 0; }
