/* Kat reads like Safari's Reader: one column of text in the system font, and
   nothing on the page that is not either the text or a way to change it. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfb; --text: #1d1d1f; --soft: #6e6e73; --faint: #a1a1a6;
  --rule: #e2e2e5; --tint: #f0f0f2; --link: #0064d2; --danger: #c4302b;
  --bar: rgb(251 251 251 / .8);
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --column: 40rem; --gutter: 1.25rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e; --text: #dedee1; --soft: #98989f; --faint: #636368;
    --rule: #38383b; --tint: #29292c; --link: #4aa3ff; --danger: #ff6961;
    --bar: rgb(28 28 30 / .8);
  }
}
@media (max-width: 26rem) { :root { --gutter: 1rem; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font: 16px/1.6 var(--sans); background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; overflow-wrap: break-word; }
body.locked > :not(#login, noscript) { display: none; }
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: 4px; }
textarea, input { background: var(--bg); 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: ")"; }

/* -- The bar ----------------------------------------------------------------- */

#bar, #composer {
  position: sticky; z-index: 2; background: var(--bar);
  -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
}
#bar { top: 0; border-bottom: 1px solid var(--rule); padding-top: env(safe-area-inset-top); }
#bar .column { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; min-height: 2.75rem; }
#bar h1 { font-size: 1rem; font-weight: 650; margin: 0 auto 0 0; letter-spacing: -.01em; }
#model { font-size: .8125rem; color: var(--soft); max-width: 55vw; text-overflow: ellipsis; text-align: right; }
#prompt { flex-basis: 100%; margin: .25rem 0 .75rem; font-size: 1rem; }

#menu { position: relative; }
#menu summary {
  list-style: none; cursor: pointer; color: var(--soft); font-size: .75rem; letter-spacing: .1em;
  padding: .6rem .25rem; margin-right: -.25rem; user-select: none; -webkit-user-select: none;
}
#menu summary::-webkit-details-marker { display: none; }
#menu[open] summary, #menu summary:hover { color: var(--text); }
#menu > div {
  position: absolute; right: 0; top: 100%; min-width: 11rem; padding: .3rem;
  background: var(--bg); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .14); display: grid;
}
#menu button { text-align: left; padding: .5rem .7rem; border-radius: 8px; font-size: .9375rem; }
#menu button:hover:not(:disabled) { background: var(--tint); }
.danger { color: var(--danger); }

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

#login { max-width: 24rem; width: 100%; margin: 22vh auto 0; padding: 0 var(--gutter); display: grid; gap: .75rem; }
#login h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; }
#login p { margin: 0; color: var(--soft); }
#login button, #send { color: var(--link); font-weight: 600; }
#login button { justify-self: start; padding: .25rem 0; }
#login-error:empty { display: none; }
#login #login-error { color: var(--danger); font-size: .875rem; }

/* -- The document ------------------------------------------------------------ */

#doc { flex: 1; padding-top: .5rem; padding-bottom: 2rem; }
#doc:empty::before { content: "Nothing here yet. Write to Kat below."; display: block; margin-top: 30vh; text-align: center; color: var(--faint); }

.day > h2 {
  display: flex; align-items: baseline; gap: .6rem; margin: 2.25rem 0 1.25rem; padding-bottom: .4rem;
  border-bottom: 1px solid var(--rule); font-size: .8125rem; font-weight: 600; color: var(--soft);
}
.day > h2 code { font: .75rem var(--mono); color: var(--faint); margin-right: auto; }

.block { margin: 0 0 1.5rem; }
.meta { display: flex; align-items: baseline; gap: .5rem; font-size: .75rem; color: var(--faint); margin-bottom: .2rem; min-height: 1.5rem; }
.meta b { color: var(--soft); font-weight: 600; }
.actions { margin-left: auto; display: flex; gap: .9rem; flex-shrink: 0; white-space: nowrap; font-weight: 400; opacity: 0; transition: opacity .12s; }
.block:hover .actions, .block:focus-within .actions, .day > h2:hover .actions, .day > h2:focus-within .actions { opacity: 1; }
@media (hover: none) { .actions { opacity: .7; } }
.actions button, .code button { font-size: .75rem; color: var(--soft); padding: .15rem 0; }
.actions button:hover, .code button:hover { color: var(--link); }

.user .body { background: var(--tint); border-radius: 10px; padding: .6rem .85rem; }
.declined .body { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--rule); }
.note { margin: -.5rem 0 1.25rem; display: flex; justify-content: center; align-items: baseline; gap: .6rem; font-size: .8125rem; color: var(--soft); text-align: center; }
.note .meta { display: contents; }
.note .meta > :not(.actions) { display: none; }
.note .actions { margin: 0; order: 2; }

.draft .body:empty::after { content: "●"; color: var(--faint); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .draft .body:empty::after { animation: 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: 650; letter-spacing: -.01em; }
.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(--tint); border-radius: 4px; padding: .1em .3em; }
.user .body code { background: var(--bg); }
.tag { font: .8125em var(--mono); color: var(--soft); background: var(--tint); border-radius: 4px; padding: .1em .35em; white-space: nowrap; }
.user .tag { background: var(--bg); }

.code { background: var(--tint); border-radius: 10px; }
.user .code { background: var(--bg); }
.code > div { display: flex; justify-content: space-between; align-items: center; padding: .3rem .85rem 0; font: .6875rem var(--mono); color: var(--faint); }
.code pre { margin: 0; padding: .4rem .85rem .75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.code > div > span:last-child { display: flex; gap: .9rem; }
.export pre { cursor: pointer; }
.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 ------------------------------------------------------------ */

#composer { bottom: 0; border-top: 1px solid var(--rule); padding: .6rem 0 max(.6rem, env(safe-area-inset-bottom)); }
#composer .column { display: flex; align-items: flex-end; gap: .75rem; }
#input { max-height: 40dvh; font-size: 1rem; }
#send { padding: .5rem 0; min-width: 2.75rem; text-align: right; }

@media print {
  #bar, #composer, .actions, .code button { display: none; }
  html { background: #fff; color: #000; }
}
