/* Kat's page, on Apple's Human Interface Guidelines: system fonts, the iOS
   text styles, grouped greys for the level above and a white sheet for the
   conversation. docs/design.md says which level lives where; the values are
   here only. */

/* One colour layer, both schemes in light-dark(): a value is written once, its
   dark reading beside it. color-scheme above makes the function resolve. The
   accents are one OKLCH wheel — even lightness and chroma, so they read as a
   family, not a set of borrowed hexes — brighter and a touch less saturated on
   a dark page. */
:root {
  color-scheme: light dark;
  /* Surfaces: the ground holds the conversations, the sheet one of them. */
  --ground: light-dark(#f2f2f7, #0d0d0f);
  --sheet:  light-dark(#ffffff, #1c1c1e);
  --menu:   light-dark(#ffffff, #2c2c2e);
  --text:   light-dark(#1d1d1f, #f2f2f7);
  --soft:   light-dark(#6e6e73, #98989f);
  --faint:  light-dark(#aeaeb2, #636368);
  --rule:   light-dark(#d8d8dc, #38383a);
  --fill:        light-dark(rgb(120 120 128 / .12), rgb(120 120 128 / .24));
  --fill-strong: light-dark(rgb(120 120 128 / .2),  rgb(120 120 128 / .36));
  --shadow: light-dark(rgb(0 0 0 / .08), rgb(0 0 0 / .5));
  --bar:    light-dark(rgb(255 255 255 / .78), rgb(28 28 30 / .78));

  /* One accent — indigo — for links, selection and Send. It is also your
     voice: your words sit on a cool indigo wash, Kat's on a warm clay one.
     Red stays apart, for what deletes. */
  --accent:      light-dark(oklch(.55 .17 266), oklch(.66 .17 266));
  --accent-soft: color-mix(in oklab, var(--accent) 12%, transparent);
  --link: var(--accent); --link-soft: var(--accent-soft);
  --danger: light-dark(#ff3b30, #ff453a);
  /* The two voices: a hue each, a soft wash of it behind every block, the
     solid on the avatar. The marks hold one mid tone for both schemes, so the
     initial on them stays legible either way. */
  --you: var(--accent); --kat: light-dark(oklch(.62 .13 48), oklch(.74 .12 48));
  --you-bg: color-mix(in oklab, var(--you) 7%, var(--sheet));
  --kat-bg: color-mix(in oklab, var(--kat) 8%, var(--sheet));
  --you-mark: oklch(.55 .17 266); --kat-mark: oklch(.56 .13 48);

  /* Tags are the one place colour carries information: one closed set, each a
     hue on the same wheel. The brace is grey until a tag colours it. */
  --star:     light-dark(oklch(.64 .13 85),  oklch(.8 .13 85));
  --open:     light-dark(oklch(.55 .14 245), oklch(.74 .13 245));
  --todo:     light-dark(oklch(.63 .15 55),  oklch(.78 .14 55));
  --boundary: light-dark(oklch(.6 .1 190),   oklch(.76 .1 190));
  --trip:     light-dark(oklch(.56 .15 300), oklch(.74 .14 300));
  --play:     light-dark(oklch(.58 .17 350), oklch(.75 .15 350));
  --tip:      light-dark(oklch(.6 .13 145),  oklch(.76 .13 145));
  --dank:     light-dark(oklch(.6 .15 15),   oklch(.76 .14 15));
  --story:    light-dark(oklch(.58 .04 260), oklch(.74 .04 260));
  --brace:    light-dark(rgb(120 120 128 / .4), rgb(120 120 128 / .5));

  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* The iOS text styles in use, by name. */
  --large: 700 2.125rem/1.2 var(--sans);       /* Large Title 34 */
  --title: 600 1.25rem/1.25 var(--sans);       /* Title 3 20 */
  --headline: 600 1.0625rem/1.3 var(--sans);   /* Headline 17 */
  --subhead: 400 .9375rem/1.35 var(--sans);    /* Subheadline 15 */
  --footnote: 400 .8125rem/1.35 var(--sans);   /* Footnote 13 */
  --caption: 600 .75rem/1.3 var(--sans);       /* Caption 12 */
  /* The reading text: 15 at Light keeps a 36rem line near 70 characters, as
     Reader does. */
  --read: 300 .9375rem/1.6 var(--sans);
  --column: 36rem; --gutter: 1rem; --radius: 12px; --tap: 2.75rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font: 16px/1.5 var(--sans); background: var(--ground); color: var(--text); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; overflow-wrap: break-word; }
body.locked > :not(#login, noscript) { display: none; }
/* Away from the screen nothing shows, so a snapshot of the page shows nothing. */
body.away > * { visibility: hidden; }
noscript p { max-width: var(--column); margin: 20vh auto; padding: 0 var(--gutter); color: var(--soft); }

.column {
  width: 100%; max-width: var(--column); margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}

button, select, textarea, input { font: inherit; color: inherit; }
button, select { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }
textarea, input { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: .5rem .75rem; width: 100%; }
textarea { display: block; resize: none; line-height: 1.45; }
textarea:focus, input:focus { outline: none; border-color: var(--faint); }
::placeholder { color: var(--faint); opacity: 1; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.host { color: var(--faint); font-size: .8em; margin-left: .3em; }
.host::before { content: "("; } .host::after { content: ")"; }

/* -- Icons and buttons ----------------------------------------------------------- */

/* The sprite holds the icons and shows nothing itself. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.375rem; height: 1.375rem; flex: none; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.icon.small { width: 1.0625rem; height: 1.0625rem; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); height: var(--tap); padding: 0 .5rem; border-radius: 10px; color: var(--link);
}
.icon-btn:hover { background: var(--fill); }
.text-button { color: var(--link); font: var(--subhead); }
/* A section's own action, such as Save: a filled capsule, so it reads as a
   button and not as a link. Bars and rows keep text buttons, as Apple's do. */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 1.125rem;
  border-radius: 999px; background: var(--link); color: #fff; font: var(--subhead); font-weight: 600;
}
.button:hover:not(:disabled) { filter: brightness(1.08); }
.button:active:not(:disabled) { filter: brightness(.92); }
.dot { width: .5625rem; height: .5625rem; border-radius: 50%; background: var(--danger); flex: none; }

/* -- Two levels ------------------------------------------------------------------ */
/*
   The page itself scrolls, as an article does, so iOS keeps its own
   scrolling and keyboard handling. Side by side, the sidebar stays put beside
   it; on a phone, body[data-pane] says which of the two is on screen.
*/

#app { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr); min-height: 100dvh; }

#side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; min-width: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .25rem .25rem 1rem; }
.side-head h1 { margin: 0; font: var(--title); }
.side-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 .5rem 1rem; }
/* A section's heading folds it, as in Finder and Mail: the chevron shows on
   hover, and always where there is no hover or the section is folded. */
.side-list .head {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 1.75rem; margin-top: .75rem;
  padding: .125rem .75rem; border-radius: 8px; text-align: left; font: var(--caption); color: var(--soft); letter-spacing: .02em;
}
.side-list .head .label { flex: 1; }
.side-list .head .icon { opacity: 0; transition: transform .2s ease, opacity .15s; }
.side-list .head[aria-expanded="true"] .icon { transform: rotate(90deg); }
.side-list .head:hover .icon, .side-list .head:focus-visible .icon, .side-list .head[aria-expanded="false"] .icon { opacity: 1; }
@media (hover: none) { .side-list .head .icon { opacity: 1; } }
.row-button {
  display: flex; align-items: center; gap: .625rem; width: 100%; min-height: 2.5rem; text-align: left;
  padding: .375rem .75rem; border-radius: 10px; font: var(--subhead);
}
.row-button:hover { background: var(--fill); }
.row-button[aria-current="true"] { background: var(--link-soft); }
.row-button .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-button .aside { color: var(--soft); font: var(--footnote); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
.side-foot { border-top: 1px solid var(--rule); padding: .375rem .5rem .5rem; }
#account { display: flex; align-items: center; gap: .625rem; width: 100%; min-height: var(--tap); padding: .25rem .5rem; border-radius: 10px; text-align: left; font: var(--subhead); }
#account:hover { background: var(--fill); }
#account .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account > .icon { color: var(--soft); }
.avatar { position: relative; width: 1.875rem; height: 1.875rem; border-radius: 50%; display: grid; place-items: center; background: var(--fill-strong); font: var(--caption); font-size: .8125rem; flex: none; }
.avatar .dot, .back .dot { position: absolute; top: .125rem; right: .125rem; border: 2px solid var(--ground); }
.back .dot { border-color: var(--sheet); }

/* The open conversation, or a panel in its place: a sheet resting on the ground. */
#sheet {
  margin: .5rem .5rem .5rem 0; min-width: 0; min-height: calc(100dvh - 1rem);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow), 0 8px 28px var(--shadow);
  display: flex; flex-direction: column;
}
.pane { display: none; flex: 1; flex-direction: column; min-width: 0; }
body[data-pane="chat"] #chat, body[data-pane="home"] #chat,
body[data-pane="tagged"] #tagged, body[data-pane="devices"] #devices, body[data-pane="share"] #share,
body[data-pane="prompt-sheet"] #prompt-sheet, body[data-pane="settings"] #settings { display: flex; }

/* The sheet's bar: translucent over the text. The conversation's slides away
   while reading down and comes back on the first move up. */
.bar {
  position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--rule);
  border-radius: var(--radius) var(--radius) 0 0; background: var(--bar);
  -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
  transition: transform .25s ease;
}
#bar.away { transform: translateY(-100%); }
.bar .row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 3.25rem; padding: 0 .375rem; }
.bar .left { display: flex; align-items: center; }
.bar .right { display: flex; justify-content: flex-end; align-items: center; }
.bar .back, .bar .done { display: none; }
.bar .done { padding: 0 .75rem; font-weight: 600; }
.bar h2, .bar .title { margin: 0; max-width: min(24rem, 60vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; font: var(--headline); padding: .25rem .5rem; border-radius: 8px; }
.bar button.title:hover:not(:disabled) { background: var(--fill); }
.bar button.title:disabled { opacity: 1; }
.title-wrap { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar .sub { margin-top: -.25rem; font: var(--footnote); color: var(--soft); }
.rename { font: var(--headline); text-align: center; width: min(16rem, 50vw); padding: .25rem .5rem; border-color: var(--link); }
#filter-bar { display: flex; align-items: center; gap: 1rem; min-height: 2.25rem; font: var(--footnote); color: var(--soft); border-top: 1px solid var(--rule); }
#filter-label { margin-right: auto; font-weight: 600; }

@media (min-width: 48rem) { .bar .done { display: inline-flex; } }

/* The sidebar hides on a wide screen. Its contents keep their width while it
   closes, so nothing reflows; its button and New move into the sheet's bar. */
.side-toggle, .side-new { display: none !important; }
@media (min-width: 48rem) {
  #app { transition: grid-template-columns .28s cubic-bezier(.2, .8, .2, 1); }
  #side { overflow: hidden; }
  #side > * { width: 17.5rem; flex: none; }
  #side > .side-list { flex: 1; }
  .side-head { padding-left: .25rem; }
  .side-head h1 { flex: 1; }
  .side-head .side-toggle { display: inline-flex !important; }
  body.side-hidden #app { grid-template-columns: 0 minmax(0, 1fr); }
  body.side-hidden #sheet { margin-left: .5rem; }
  body.side-hidden .bar .side-toggle, body.side-hidden .bar .side-new { display: inline-flex !important; }
  #sheet { transition: margin .28s cubic-bezier(.2, .8, .2, 1); }
}

/* -- Phone: one level at a time --------------------------------------------------- */

@media (max-width: 47.99rem) {
  #app { display: block; }
  #side { position: static; height: auto; min-height: 100dvh; padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
  .side-head { padding-top: .5rem; }
  .side-head h1 { font: var(--large); }
  .side-list { overflow: visible; }
  .row-button { min-height: var(--tap); font: 400 1.0625rem/1.35 var(--sans); }
  .side-list .head { min-height: var(--tap); margin-top: .25rem; }
  #sheet { margin: 0; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .bar { border-radius: 0; padding-top: env(safe-area-inset-top); }
  .bar .back { display: inline-flex; }
  body[data-pane="home"] #sheet { display: none; }
  body:not([data-pane="home"]) #side { display: none; }
  /* The sheet comes in from the side, as a pushed screen does. */
  body:not([data-pane="home"]) #sheet { animation: push .28s cubic-bezier(.2, .8, .2, 1); }
  /* Dynamic Type: the reading text follows the phone's text size, from 15 at
     the standard size. */
  @supports (font: -apple-system-subheadline) {
    #doc { font: -apple-system-subheadline; font-weight: 300; line-height: 1.6; }
  }
}
@keyframes push { from { transform: translateX(24%); opacity: .4; } }
@media (prefers-reduced-motion: reduce) {
  #sheet { animation: none !important; transition: none !important; }
  .bar, #app, .side-list .head .icon { transition: none !important; }
}

/* -- Menus ------------------------------------------------------------------------ */

/* Popovers in the top layer, placed by menus.js; on a phone they take the
   width of the screen. */
.menu {
  position: fixed; inset: auto; margin: 0; min-width: 15rem; max-width: min(20rem, calc(100vw - 1rem));
  max-height: calc(100dvh - 4rem); overflow: auto; padding: .375rem;
  background: var(--menu); color: var(--text); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 10px 34px rgb(0 0 0 / .18);
}
.menu:popover-open { display: grid; }
@media (max-width: 30rem) { .menu { left: .5rem !important; right: .5rem !important; max-width: none; } }
.menu button { display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 2.5rem; text-align: left; padding: .375rem .625rem; border-radius: 8px; font: var(--subhead); font-size: 1rem; }
.menu button:hover:not(:disabled) { background: var(--fill); }
.menu .icon { color: var(--soft); }
.menu .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .aside { margin-left: auto; padding-left: .75rem; color: var(--soft); font: var(--footnote); white-space: nowrap; }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: .3rem .375rem; }
.menu .menu-head { margin: .375rem .625rem .125rem; font: var(--caption); color: var(--soft); letter-spacing: .05em; text-transform: uppercase; }
/* The tick stands where it would be on every row, so the names line up. */
#filter-list button .icon:first-child, #tag-menu button .icon:first-child { visibility: hidden; }
#filter-list button[aria-current="true"] .icon:first-child, #tag-menu button[aria-pressed="true"] .icon:first-child { visibility: visible; color: var(--link); }
.danger, .menu .danger .icon { color: var(--danger); }
.swatch { width: .625rem; height: .625rem; border-radius: 50%; background: currentColor; flex: none; margin-left: auto; }

/* -- Panels: grouped lists, as in Settings --------------------------------------- */

.panel .column { display: grid; gap: .5rem; padding-block: 1rem 2.5rem; font: var(--subhead); }
.panel p { margin: 0; }
.group-head { margin: 1rem 1rem 0 !important; font: var(--footnote); color: var(--soft); text-transform: uppercase; letter-spacing: .03em; }
.group-foot { margin: 0 1rem .5rem !important; font: var(--footnote); color: var(--soft); }
.group { list-style: none; margin: 0; padding: 0; background: var(--fill); border-radius: var(--radius); overflow: hidden; }
.group:empty { display: none; }
.group > li { display: flex; flex-wrap: wrap; align-items: center; gap: .125rem .75rem; min-height: var(--tap); padding: .625rem 1rem; }
.group > li + li { border-top: 1px solid var(--rule); }
.group > li > b { font-weight: 600; }
.group .two { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.group .two small { font: var(--footnote); color: var(--soft); }
.group .this { color: var(--soft); font: var(--footnote); }
/* A view's blocks: each with where it is from and its tags, then its text. */
.group > li.view-block { display: block; cursor: pointer; }
.view-block .tags { margin-left: auto; display: flex; gap: .5rem; }
.view-block .body { font: var(--read); }
.view-block .more { color: var(--faint); font: var(--footnote); }
.group button { color: var(--link); font: var(--subhead); }
.group select { color: var(--soft); font: var(--footnote); margin-left: auto; }
.group > li.link { cursor: pointer; }
.group > li.link:hover { background: var(--fill); }
.group > li.link > .icon { color: var(--faint); margin-left: auto; }
.panel textarea { resize: vertical; }

/* Settings and Prompt are editors: the text takes the sheet's whole width and
   the height under the bar, side by side once there is room for two. What a
   field holds is behind the ⓘ at its heading, a native disclosure. */
.panel.editing .column { max-width: none; flex: 1; display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.editors { flex: 1; display: grid; gap: 1rem 1.5rem; grid-auto-rows: minmax(18rem, 1fr); }
@media (min-width: 64rem) { #settings .editors { grid-template-columns: 1fr 1fr; } }
/* An editor's sheet is exactly the screen tall, so the fields fill it and
   scroll inside rather than the page growing with them. */
body[data-pane="settings"] #sheet, body[data-pane="prompt-sheet"] #sheet { height: calc(100dvh - 1rem); }
.panel.editing { min-height: 0; }
.editor { display: flex; flex-direction: column; gap: .5rem; min-height: 0; }
.editor textarea { flex: 1; min-height: 12rem; resize: none; }
.about > summary { display: flex; align-items: center; gap: .375rem; min-height: var(--tap); list-style: none; cursor: pointer; width: fit-content; color: var(--soft); }
.about > summary::-webkit-details-marker { display: none; }
.about > summary .group-head { margin: 0 0 0 1rem !important; }
.about > summary .icon { color: var(--faint); }
.about[open] > summary .icon, .about > summary:hover .icon { color: var(--link); }
.about > .group-foot { margin: 0 1rem .5rem !important; max-width: var(--column); }
/* On a phone the page scrolls, as the keyboard takes half of it: each field
   is most of a screen tall instead. */
@media (max-width: 47.99rem) {
  body[data-pane="settings"] #sheet, body[data-pane="prompt-sheet"] #sheet { height: auto; }
  .editors { grid-auto-rows: auto; }
  .editor textarea { flex: none; height: max(12rem, calc(100dvh - 11rem)); }
}
.panel .mono { font: .8125rem/1.5 var(--mono); }
.panel code { font: .875em var(--mono); }
.panel [role=status] { color: var(--soft); font: var(--footnote); }
.panel [role=status].error { color: var(--danger); }
.inline { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.inline input { flex: 1; min-width: 10rem; font: .8125rem var(--mono); }
.inline select { font: var(--subhead); }

/* The invite: its QR code beside the link, above it on a narrow screen. Small,
   for a camera held up to this screen: about 2.7 px a module. */
#invite { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; margin-top: .25rem; }
#invite > div:last-child { flex: 1 1 14rem; display: grid; gap: .5rem; }
#invite p { color: var(--soft); font: var(--footnote); }
.qr svg { display: block; width: 7.5rem; height: 7.5rem; border-radius: 6px; }

/* A reader reads: no composer. */
body.reader #composer { display: none; }

/* -- Login ------------------------------------------------------------------------ */

/* The dark (ui/void.js, index.html). Black whatever the scheme, the field
   over all of it and invisible, the buttons where the motes gather. */
body.locked { background: #000; }
#login {
  --eye: clamp(7.5rem, 34vmin, 18.75rem); --whisper: rgb(255 228 196 / .62);
  position: fixed; inset: 0; overflow: hidden; background: #000; color: var(--whisper);
  font: 300 .875rem/1.5 var(--sans); letter-spacing: .02em; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#void { position: absolute; inset: 0; width: 100%; height: 100%; }
#login h1, #login-lead {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0;
}
#link {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; outline: 0;
  background: transparent; color: transparent; caret-color: transparent; font-size: 16px; cursor: default;
}
#link::selection { background: transparent; color: transparent; }
/* The sign-in link, dotted were it ever seen: it is a secret, but a field
   for one would be offered to a password manager (index.html). */
#login .secret { -webkit-text-security: disc; }
#open, #unlock {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 1;
  width: var(--eye); height: calc(var(--eye) * .5); border-radius: 50%;
  background: transparent; color: transparent; font-size: 0; cursor: pointer;
}
#unlock { height: calc(var(--eye) * .9); width: calc(var(--eye) * .9); }
#open:focus-visible, #unlock:focus-visible, #hush:focus-visible { outline: 1px solid rgb(255 228 196 / .3); outline-offset: 4px; }
#login:not([data-mood="eye"]) #open { display: none; }
#login #login-error {
  position: absolute; left: 50%; top: calc(50% + var(--eye) * .42); translate: -50% 0; z-index: 1;
  width: min(22rem, 100% - 3rem); margin: 0; text-align: center; color: var(--whisper);
  animation: whisper 2.4s ease-out both; pointer-events: none;
}
#login-error:empty { display: none; }
#login[data-hint]::after {
  content: attr(data-hint); position: absolute; left: 50%; bottom: 16%; translate: -50% 0;
  font: 200 .75rem var(--sans); letter-spacing: .9em; text-indent: .9em; color: var(--whisper);
  animation: hint 8s ease-in-out both; pointer-events: none;
}
#hush {
  position: absolute; right: max(.5rem, env(safe-area-inset-right)); bottom: max(.5rem, env(safe-area-inset-bottom));
  z-index: 1; width: var(--tap); height: var(--tap); background: transparent; cursor: pointer; opacity: .3;
}
#hush::before {
  content: ""; display: block; margin: auto; width: 4px; height: 4px; border-radius: 50%;
  background: rgb(255 228 196); box-shadow: 0 0 6px 1px rgb(255 214 160 / .6);
}
#hush[aria-pressed="true"]::before { background: transparent; box-shadow: inset 0 0 0 1px rgb(255 228 196 / .7); }
@keyframes whisper { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
@keyframes hint { 0%, 100% { opacity: 0; } 45% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { #login #login-error, #login[data-hint]::after, #brandmark { animation-duration: .01s; } }
#passkey-status:empty { display: none; }
/* The madman mark at the foot of the dark: the wordmark in ash (a logotype, so
   exempt from the contrast minimum), its full stop an ember mote — the one warm
   light, the same the motes are made of. It never takes a tap, so a paste still
   lands in the field beneath it. */
#brandmark {
  --near: 0; /* void.js: 0 far, 1 when the pointer is at the mark. */
  position: absolute; left: 50%; bottom: max(1.75rem, calc(env(safe-area-inset-bottom) + .5rem)); translate: -50% 0;
  z-index: 1; margin: 0; display: flex; align-items: center;
  font: 700 .8125rem var(--sans); font-variant-caps: all-small-caps; letter-spacing: .14em; text-indent: .14em;
  /* Ash when far, warming toward bone as the pointer nears; a logotype, so the
     low contrast is exempt from the contrast minimum. */
  color: color-mix(in oklab, #3d3833, #f2e6d8 calc(var(--near) * 55%));
  pointer-events: none; animation: whisper 2.4s ease-out both;
}
#brandmark .mote {
  width: 4px; height: 4px; margin-left: .18em; border-radius: 50%; background: #fff4e2;
  box-shadow: 0 0 calc(6px + var(--near) * 8px) 2px rgb(255 214 160 / .7),
              0 0 calc(15px + var(--near) * 14px) 5px rgb(255 214 160 / .22);
}

/* -- The conversation --------------------------------------------------------------- */

/* Bold is set explicitly: the default `bolder` from 300 lands on 400 and would
   look like plain text. */
#doc { flex: 1; padding-top: .5rem; padding-bottom: 2rem; font: var(--read); }
.body strong { font-weight: 600; }
#doc:empty::before { content: "Nothing here yet. Write to Kat below."; display: block; margin-top: 30vh; text-align: center; color: var(--faint); font: var(--subhead); }

.day > h2 {
  display: flex; align-items: baseline; gap: .5rem; margin: 1.75rem 0 .5rem;
  -webkit-user-select: none; user-select: none;
  font: var(--caption); color: var(--soft); text-transform: uppercase; letter-spacing: .06em;
}
.day > h2 code { font: .75rem var(--mono); color: var(--faint); letter-spacing: 0; margin-right: auto; }

/* A block: who and when, then the text, with a curly brace on its left. */
.block { position: relative; margin: .25rem 0; padding: .375rem .5rem .75rem 1.25rem; border-radius: var(--radius); transition: background .15s; }
/* A later part of the same answer sits close under the one before, with its
   tags and actions but no second name and time. */
.part { margin-top: -.25rem; }
.part .meta > b, .part .meta > time, .part .meta > .by, .part .meta > .avatar { display: none; }
/* The two voices, each on a soft wash of its hue; your words a step heavier
   than Kat's, and the name and avatar above say who. A note stays plain, so it
   never reads as either voice. Selection wins over the wash. */
.block.user { background: var(--you-bg); }
.block.kat { background: var(--kat-bg); }
.block.note { background: none; }
.user > .body { font-weight: 400; }
.block.selected { background: var(--accent-soft); }
/* With room to spare, the brace hangs in the margin and the text keeps the column's edge. */
@media (min-width: 48rem) { .block { margin-inline: -1.25rem -.5rem; } }

/* The brace: grey until tagged, then in the colours of its tags, one per
   quarter (app.js sets --c on each). Four quarter-pieces, borders only. */
.brace { position: absolute; left: .25rem; top: .75rem; bottom: .75rem; width: .625rem; pointer-events: none; }
.brace i { position: absolute; height: calc(25% + 1px); border: 0 solid var(--c, var(--brace)); }
.brace i:nth-child(1) { top: 0; left: calc(50% - 1px); right: 0; border-width: 1.5px 0 0 1.5px; border-top-left-radius: .4rem; }
.brace i:nth-child(2) { top: 25%; left: 0; width: calc(50% + .5px); border-width: 0 1.5px 1.5px 0; border-bottom-right-radius: .4rem; }
.brace i:nth-child(3) { top: calc(50% - .5px); left: 0; width: calc(50% + .5px); border-width: 1.5px 1.5px 0 0; border-top-right-radius: .4rem; }
.brace i:nth-child(4) { top: calc(75% - 1px); left: calc(50% - 1px); right: 0; border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: .4rem; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .125rem .5rem; min-height: 1.75rem; font: var(--footnote); color: var(--soft); -webkit-user-select: none; user-select: none; }
.meta b { color: var(--text); font-weight: 600; }
/* The speaker's avatar: a monogram in the voice's solid hue, so who is talking
   reads at a glance. Gone on a later part, as the name and time are. */
.meta .avatar { width: 1.375rem; height: 1.375rem; font: var(--caption); font-size: .6875rem; color: #fff; }
.block.user .meta .avatar { background: var(--you-mark); }
.block.kat .meta .avatar { background: var(--kat-mark); }
.meta .said { font-style: italic; color: var(--faint); }
.tagword { font-weight: 600; }
@media (hover: hover) { button.tagword:hover { text-decoration: line-through; } }
.c-star { color: var(--star); } .c-open { color: var(--open); } .c-todo { color: var(--todo); } .c-boundary { color: var(--boundary); }
.c-trip { color: var(--trip); } .c-play { color: var(--play); } .c-tip { color: var(--tip); }
.c-dank { color: var(--dank); } .c-story { color: var(--story); }
.meta .icon { width: 1rem; height: 1rem; }
.sign.kept { width: .375rem; height: .375rem; border-radius: 50%; background: var(--faint); }

/* A block's actions show on hover, or on a tap that selects it. */
.actions { margin-left: auto; display: flex; align-items: center; gap: .125rem; opacity: 0; pointer-events: none; transition: opacity .12s; }
@media (hover: hover) { .block:hover .actions, .day > h2:hover .actions { opacity: 1; pointer-events: auto; } }
.block.selected .actions, .block:focus-within .actions, .day > h2:focus-within .actions { opacity: 1; pointer-events: auto; }
.actions button, .code button { display: inline-flex; align-items: center; justify-content: center; min-width: 2.25rem; height: 2.25rem; border-radius: 8px; color: var(--soft); }
.actions button:hover, .code button:hover { color: var(--text); background: var(--fill); }
.actions button[aria-pressed="true"] { color: var(--star); }
.actions .icon, .code .icon { width: 1.0625rem; height: 1.0625rem; }

.t-hidden > .body, .t-hidden > .brace { opacity: .45; transition: opacity .15s; }
.t-hidden:hover > .body, .t-hidden.selected > .body { opacity: .8; }
.t-declined .body { text-decoration: line-through; text-decoration-color: var(--rule); }

/* Notes from Kat or the page: one quiet line, centred. */
.note { margin: .5rem 0 1rem; padding: 0; display: flex; justify-content: center; align-items: center; gap: .5rem; font: var(--footnote); color: var(--soft); text-align: center; }
.note .meta { display: contents; }
.note .meta > :not(.actions) { display: none; }
.note .actions { margin: 0; order: 2; opacity: 1; pointer-events: auto; }

/* While Kat thinks, before the first word. */
.draft .body:empty::after { content: "Kat is thinking…"; color: var(--faint); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .draft .body:empty::after, .block, .actions { animation: none; transition: none; } }

.body.source { font: .8125rem/1.55 var(--mono); white-space: pre-wrap; }
.body textarea { font: .875rem/1.55 var(--mono); }

/* -- Rendered Markdown --------------------------------------------------------- */

.body > :first-child { margin-top: 0; }
.body > :last-child { margin-bottom: 0; }
.body p, .body ul, .body ol, .body blockquote, .body .table, .body .code { margin: 0 0 .85em; }
.body h1, .body h2, .body h3, .body h4, .body h5, .body h6 { margin: 1.4em 0 .4em; line-height: 1.3; font-weight: 600; }
.body h1 { font-size: 1.3rem; } .body h2 { font-size: 1.15rem; } .body h3 { font-size: 1rem; }
.body h4, .body h5, .body h6 { font-size: .875rem; color: var(--soft); }
.body ul, .body ol { padding-left: 1.4em; }
.body li { margin: .15em 0; }
.body li > ul, .body li > ol { margin: .15em 0 0; }
.body blockquote { padding-left: .9em; border-left: 2px solid var(--rule); color: var(--soft); }
.body hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5em 0; }
.body code { font: .875em var(--mono); background: var(--fill); border-radius: 4px; padding: .1em .3em; }
.tag { font: .8125em var(--mono); color: var(--soft); background: var(--fill); border-radius: 4px; padding: .1em .35em; white-space: nowrap; }

/* Code, and the ExoCortex export: a grey card with its label and Copy. */
.code { background: var(--fill); border-radius: 10px; }
.code > div { display: flex; justify-content: space-between; align-items: center; padding: .125rem .25rem 0 .85rem; font: var(--caption); color: var(--soft); }
.export > div > span:first-child { text-transform: uppercase; letter-spacing: .05em; }
.code pre { margin: 0; padding: .25rem .85rem .75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.code > div > span:last-child { display: flex; }
.code pre code { background: none; padding: 0; font: .8125rem/1.5 var(--mono); white-space: pre; }
.export pre code { white-space: pre-wrap; }

.table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.body table { border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.body th, .body td { padding: .35rem .75rem .35rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.body th { font-weight: 600; color: var(--soft); white-space: nowrap; }
.body .right { text-align: right; padding: .35rem 0 .35rem .75rem; }
.body .center { text-align: center; }

/* -- The composer: one row, the model, the text, send ----------------------------- */

#composer {
  position: sticky; bottom: 0; z-index: 2; padding: .5rem 0 max(.625rem, env(safe-area-inset-bottom));
  background: var(--bar); -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
  border-radius: 0 0 var(--radius) var(--radius);
}
.compose-row { display: flex; align-items: flex-end; gap: .5rem; }
.field { flex: 1; min-width: 0; border: 1px solid var(--rule); border-radius: 1.25rem; background: var(--sheet); padding: 0 .875rem; box-shadow: 0 1px 2px var(--shadow); }
.field:focus-within { border-color: var(--faint); }
/* 16px, not the 15px of the text above: below that, iOS Safari zooms the page
   on focus. The weight matches the text. */
#input { border: 0; border-radius: 0; padding: .5rem 0; background: none; max-height: 40dvh; font-size: 1rem; font-weight: 300; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: .125rem; height: 2.5rem;
  padding: 0 .5rem 0 .75rem; border-radius: 999px; background: var(--fill); font: var(--footnote); font-weight: 600; color: var(--soft);
}
.chip:hover { color: var(--text); }
.chip:focus-within { outline: 2px solid var(--link); outline-offset: 1px; }
/* The real picker lies over the chip, unseen: a tap opens the system's own. */
.chip select { position: absolute; inset: 0; width: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.send { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; background: var(--link); color: #fff; }
.send:disabled { background: var(--fill-strong); color: var(--sheet); opacity: 1; }
/* On a phone the text gets the whole width, and the model and Send sit on a
   row below it, model left, Send right under the thumb. */
@media (max-width: 47.99rem) {
  .compose-row { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "field field field" "chip . send"; align-items: center; }
  .compose-row .field { grid-area: field; }
  .compose-row .chip { grid-area: chip; justify-self: start; }
  .compose-row .send { grid-area: send; }
}

@media print {
  #side, #bar, #composer, .menu, .actions, .code button { display: none; }
  html, #sheet { background: #fff; color: #000; border: 0; box-shadow: none; }
}
