/* BIMeta Nova. The colours are the desktop app's. */
:root {
  --back: #f2f5f9; --surface: #ffffff; --ink: #14202e; --muted: #566678; --line: #d3dce7; --control: #6b7a8c;
  --accent: #1f5fd1; --fill: #1f5fd1; --fill-ink: #ffffff; --danger: #b0323c; --notice: #fbecd4; --notice-ink: #6b3d00;
  --you: #eaf2ff; --code: #f3f5f8; --hover: #e3ecfb; --focus: #14202e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --back: #11161c; --surface: #1a212a; --ink: #e6ecf3; --muted: #a3b1c2; --line: #3a4656; --control: #8190a3;
    --accent: #7daeff; --fill: #2b64d8; --fill-ink: #ffffff; --danger: #ff9097; --notice: #3b2c0e; --notice-ink: #f6dda8;
    --you: #1f3556; --code: #10151b; --hover: #26384f; --focus: #f2c94c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 system-ui, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--back); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; height: auto; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.35rem; margin: 0 0 1rem; }
h3 { font-size: 1.05rem; margin: 0 0 .35rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--surface); padding: .5rem .75rem; border-radius: 6px; }
.small { font-size: .85rem; color: var(--muted); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.top nav { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.top form { margin: 0; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.who { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
.button { display: inline-block; background: var(--fill); color: var(--fill-ink); border: 1px solid var(--fill); border-radius: 8px; padding: .4rem .95rem; text-decoration: none; white-space: nowrap; }
.button:hover { filter: brightness(1.08); }
.button.big { font-size: 1.1rem; padding: .7rem 1.4rem; }
.plain { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .45rem; color: var(--accent); }
.plain:hover { background: var(--hover); }

.flash, .notice { margin: .75rem auto; max-width: 60rem; padding: .65rem 1rem; border-radius: 8px; background: var(--notice); color: var(--notice-ink); width: calc(100% - 2rem); }
.notice a, .flash a { color: inherit; font-weight: 600; }

.page { max-width: 60rem; margin: 0 auto; padding: 2rem 1rem 3rem; }
.page.narrow { max-width: 34rem; text-align: center; padding-top: 4rem; }
.prose { max-width: 44rem; }
.prose h2 { margin-top: 2rem; }
.foot { display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: center; padding: 1.5rem 1rem 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* Nova: her still picture, and over it the moving face once it is being drawn. The background is the picture's. */
.nova-stage { aspect-ratio: 4 / 5; overflow: hidden; background: #010616; }
.nova-stage img, .nova-stage canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.nova-stage canvas, .nova-stage.alive img { display: none; }
.nova-stage.alive canvas { display: block; }
.nova-stage.alive { cursor: pointer; }

.companies { list-style: none; padding: 0; margin: 1.5rem 0; }
.companies li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1.1rem; margin-bottom: .75rem; }
.companies strong { display: block; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row form { margin: 0; }

/* ---------------------------------------------------------------- chat */
body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.chat { flex: 1; min-height: 0; display: grid; grid-template-columns: 16rem 1fr; }
.side { display: flex; flex-direction: column; gap: .6rem; min-height: 0; padding: .75rem; border-right: 1px solid var(--line); background: var(--surface); }
.wide-button { width: 100%; }
#history { flex: 1; overflow: hidden auto; list-style: none; margin: 0; padding: 0; }
#history li { display: flex; align-items: center; border-radius: 6px; }
#history li.selected, #history li:hover { background: var(--hover); }
#history button { background: none; border: 0; border-radius: 6px; padding: .35rem .5rem; }
#history .open { flex: 1; min-width: 0; text-align: left; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#history .remove { color: var(--muted); }
#history .remove:hover { color: var(--danger); }
.side p { margin: 0; }
.search { width: 100%; font: inherit; font-size: .95rem; color: var(--ink); background: var(--back); border: 1px solid var(--control); border-radius: 8px; padding: .3rem .6rem; }
#history .rename { color: var(--muted); }
#history .rename:hover { color: var(--accent); }
#history .none { padding: .35rem .5rem; }
.rename-form { flex: 1; min-width: 0; margin: 0; padding: .15rem .25rem; }
.rename-form input { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--accent); border-radius: 6px; padding: .15rem .35rem; }
/* Where there is a pointer to hover with, the pencil shows on the line in use. */
@media (hover: hover) {
  #history li:not(:hover):not(:focus-within):not(.selected) .rename { opacity: 0; }
}
.download { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.download .choices { display: inline-flex; gap: .25rem; }
.download .choices button { border-color: var(--line); }
#download-chat { position: relative; font-size: .9rem; }
#download-chat .choices { position: absolute; top: 100%; left: 0; z-index: 3; flex-direction: column; align-items: stretch; background: var(--surface); border: 1px solid var(--control); border-radius: 8px; padding: .3rem; white-space: nowrap; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.edit { display: flex; flex-direction: column; gap: .4rem; margin-left: 15%; }
.edit textarea { width: 100%; min-height: 4.5rem; resize: vertical; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: .6rem .8rem; }
.edit-row { display: flex; justify-content: flex-end; gap: .5rem; }
.talk { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
#toggle-side { display: none; }
.company { font-weight: 600; text-decoration: none; }
.project { display: flex; align-items: center; gap: .4rem; min-width: 0; color: var(--muted); font-size: .9rem; }
select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: 6px; padding: .2rem .35rem; max-width: 16rem; }
.credits { margin-left: auto; display: flex; gap: .6rem; font-size: .9rem; color: var(--muted); }
.credits.low, .credits.out, .credits.off { color: var(--danger); }
.messages { flex: 1; overflow: auto; padding: 1rem; }
.empty { text-align: center; margin: 12vh auto 0; max-width: 30rem; }
.turn { max-width: 52rem; margin: 0 auto 1.25rem; display: flex; flex-direction: column; gap: .6rem; }
.bubble { border-radius: 12px; padding: .65rem .9rem; overflow-wrap: anywhere; }
.bubble.you { align-self: flex-end; background: var(--you); max-width: 85%; white-space: pre-wrap; }
.bubble.nova { background: var(--surface); border: 1px solid var(--line); }
.speaker { display: block; font-size: .8rem; font-weight: 600; color: var(--accent); margin-bottom: .2rem; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer h3, .answer h4, .answer h5, .answer h6 { margin: 1rem 0 .4rem; }
.answer code { background: var(--code); border-radius: 4px; padding: .05rem .3rem; font-family: ui-monospace, Consolas, monospace; font-size: .92em; }
.answer pre { margin: 0; padding: .75rem; overflow: auto; background: var(--code); border-radius: 8px; }
.answer pre code { padding: 0; background: none; }
.code { position: relative; margin: .6rem 0; }
.code .plain { position: absolute; top: .25rem; right: .25rem; font-size: .8rem; background: var(--code); }
.table { overflow-x: auto; }
table { border-collapse: collapse; margin: .6rem 0; }
th, td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; vertical-align: top; }
th { background: var(--code); }
blockquote { margin: .6rem 0; padding-left: .8rem; border-left: 3px solid var(--line); color: var(--muted); }
.thinking { color: var(--muted); }
.actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .4rem; font-size: .9rem; }
.actions-row .model { margin-left: auto; }
.composer { width: calc(100% - 2rem); max-width: 52rem; margin: 0 auto; background: var(--surface); border: 1px solid var(--control); border-radius: 12px; padding: .5rem .6rem; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { width: 100%; min-height: 3rem; max-height: 12rem; resize: vertical; border: 0; background: none; color: var(--ink); font: inherit; padding: .25rem; }
.composer textarea:focus-visible { outline: none; }
.composer-row { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; }
.composer-row #count { margin-right: auto; }
.disclaimer { text-align: center; margin: .35rem 0 .5rem; }
.chat .notice { margin: 0 auto .5rem; max-width: 52rem; }
.chat { position: relative; }
.presence { display: flex; flex-direction: column; justify-content: center; min-height: 0; overflow: hidden; background: #010616; }
.presence .nova-stage { width: 100%; min-height: 0; -webkit-mask-image: linear-gradient(transparent, #000 9%, #000 91%, transparent); mask-image: linear-gradient(transparent, #000 9%, #000 91%, transparent); }
.presence .mood { margin: 0; min-height: 1.6em; text-align: center; font-size: .9rem; color: #a8d8ff; }
#toggle-face { margin-left: auto; }
.credits:not([hidden]) ~ #toggle-face { margin-left: 0; }

/* Room beside the conversation: she sits there. */
@media (min-width: 1100px) {
  .chat { grid-template-columns: 16rem minmax(0, 1fr) 19rem; }
  .chat.no-face { grid-template-columns: 16rem 1fr; }
  /* The project's name gives way first, so that the top bar stays on one line. */
  .bar .project { flex: 1 1 9rem; max-width: 19rem; }
  .bar .project select { flex: 1; min-width: 0; }
}
/* Less room: a small picture of her at the end of the top bar. */
@media (max-width: 1099.98px) {
  .presence { position: absolute; top: .3rem; right: .5rem; width: 3.5rem; height: 4rem; border-radius: 10px; justify-content: flex-start; }
  .presence .nova-stage { width: 138%; margin: -20% 0 0 -19%; flex: none; -webkit-mask-image: none; mask-image: none; }
  .presence .mood { display: none; }
  .chat:not(.no-face) .bar { min-height: 4.6rem; padding-right: 4.75rem; }
  .project { max-width: 100%; }
  .project select { min-width: 0; flex: 0 1 auto; }
}

@media (max-width: 760px) {
  .who { display: none; }
  .chat { grid-template-columns: 1fr; }
  .side { display: none; border-right: 0; }
  .chat.side-open .side { display: flex; }
  .chat.side-open .messages, .chat.side-open .composer, .chat.side-open .disclaimer { display: none; }
  .chat.side-open { grid-template-rows: minmax(0, 1fr) auto; }
  .chat.side-open .talk { order: 2; }
  .chat.side-open .presence { display: none; }
  .chat.side-open .bar { padding-right: 1rem; min-height: 0; }
  #toggle-side { display: inline-block; }
  .credits { margin-left: 0; }
  /* The top bar keeps to three lines: "Download chat" shows as "Download", and is still read out in full. */
  .bar { column-gap: .5rem; }
  .bar .rest { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* ---------------------------------------------------------------- printing an answer or a chat (export.js) */
#print { display: none; }
@page { margin: 18mm; }
@media print {
  body.printing { display: block; height: auto; }
  html, body.printing { background: #fff; }
  body.printing > *:not(#print) { display: none !important; }
  /* Printed in dark ink whatever the screen's colours are. */
  body.printing > #print { --ink: #14202e; --muted: #566678; --line: #c5cfdc; --code: #f1f3f7; --accent: #1f5fd1; display: block; color: var(--ink); font-size: 11pt; overflow-wrap: break-word; }
  #print h1 { font-size: 18pt; margin: 0 0 4pt; }
  #print h2 { font-size: 9pt; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 16pt 0 4pt; break-after: avoid; }
  #print .about { color: var(--muted); font-size: 9pt; }
  #print .asked { white-space: pre-wrap; }
  #print pre { white-space: pre-wrap; }
  #print .code .plain { display: none; }
  #print table { width: 100%; }
  #print tr { break-inside: avoid; }
}
