/*
 * Magic Vibe — a chat with Codex that reads like the terminal it replaces.
 *
 * One column, one typeface, one accent. Google Sans Code is self-hosted under
 * `public/fonts/`: the workbench is loopback-only and works with no network,
 * and a stylesheet that fetched a font would tell Google every time it opened.
 */
@font-face {
  font-family: 'Google Sans Code';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/google-sans-code.ttf') format('truetype');
}

@font-face {
  font-family: 'Google Sans Code';
  font-style: italic;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/google-sans-code-italic.ttf') format('truetype');
}

:root {
  --bg: #0e0f11;
  --panel: #17191d;
  --panel-raised: #1f2227;
  --border: #2a2d33;
  --border-soft: #22252a;
  --text: #e4e6ea;
  --muted: #8b919c;
  --faint: #5d626b;
  --accent: #7cb7ff;
  --ok: #7ddc9a;
  --error: #ff8f8f;
  --warn: #ffc978;
  /*
   * Claude's own colour, for everything of Claude's: its run's box, mark,
   * spinner and report. Blue stays Codex's and the plan's, so who did what
   * reads at a glance.
   */
  --claude: #d97757;
  --radius: 6px;
  --mono: 'Google Sans Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* `hidden` always wins: a component's own `display` must never resurrect a
   control the page has taken away. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15.5px;
  line-height: 1.55;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

button {
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--muted);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------- the bar */

/*
 * Three columns, the outer two equal, so the chat chooser sits in the centre
 * of the bar whatever is beside it: the session and project (and the project's
 * settings) on the left, the chat actions on the right.
 */
.bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  /* The same margin on all four sides, as the composer has. */
  padding: 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.bar-start {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.bar-center {
  justify-self: center;
}

/* An icon-only button beside the project: quiet until hovered. */
.bar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-color: transparent;
  color: var(--muted);
}

.bar-icon:hover:not(:disabled) {
  border-color: transparent;
  color: var(--text);
}

.bar-icon[hidden] {
  display: none;
}

/*
 * The chat actions, at the far end of the bar. Each is a quiet button that
 * spells out its own keyboard shortcut as keycaps before its name, so the
 * shortcut is learnt by looking rather than by hovering.
 */
.bar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-self: end;
}

.key-action {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.65rem 0.25rem 0.4rem;
  border-color: transparent;
  color: var(--muted);
  font-size: 0.9em;
}

/* Hover brightens the words and the keys, and draws no box around them. */
.key-action:hover:not(:disabled) {
  border-color: transparent;
  color: var(--text);
}

.key-action:hover:not(:disabled) kbd {
  border-color: var(--muted);
  color: var(--text);
}

.key-action .keys {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.key-action kbd {
  min-width: 1.6em;
  height: 1.6em;
  font-size: 0.78em;
}

.key-action .plus {
  color: var(--faint);
  font-size: 0.85em;
}

.key-action.danger:hover:not(:disabled) {
  color: var(--error);
}

.key-action.danger:hover:not(:disabled) kbd {
  border-color: rgb(255 143 143 / 35%);
  color: var(--error);
}

/* The public door's session, and how to leave it. */
.sign-out {
  gap: 0.5rem;
  padding-left: 0.65rem;
}

.sign-out-session {
  color: var(--text);
}

.sign-out:hover:not(:disabled) {
  color: var(--text);
}

/*
 * The public door's sign-in: alone on an empty page. The rest of the page is
 * not drawn behind it, and the box has no card of its own — a title, one line,
 * the key and the button, in one narrow centred column.
 */
body.signed-out > :not(.sign-in) {
  display: none;
}

.sign-in {
  width: min(20rem, calc(100vw - 2rem));
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
}

.sign-in::backdrop {
  background: var(--bg);
}

.sign-in-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  text-align: center;
}

.sign-in-title {
  margin: 0;
  font-size: 1.35em;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sign-in-hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9em;
}

.sign-in-key {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  text-align: center;
  letter-spacing: 0.08em;
}

.sign-in-key::placeholder {
  color: var(--faint);
  letter-spacing: normal;
}

.sign-in-key:focus {
  border-color: var(--muted);
  outline: none;
}

.sign-in-submit {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-color: var(--border);
  border-radius: 8px;
  background: var(--panel-raised);
}

.sign-in-submit:hover:not(:disabled) {
  border-color: var(--muted);
}

.sign-in-submit kbd {
  height: 1.5em;
  font-size: 0.72em;
}

/* Holds its line even when empty, so a refusal does not move the column. */
.sign-in-note {
  min-height: 1.4em;
  margin: 0.25rem 0 0;
  color: var(--error);
  font-size: 0.88em;
}

/* ------------------------------------------------------------- the log */

.log {
  overflow-y: auto;
  padding: 1.25rem 1.25rem 2rem;
  /* The conversation reads one step larger than the controls around it. */
  font-size: 17.5px;
}

/* The welcome is the one box that is not a message, so it keeps a reading
   width; every turn uses the whole window. */
.welcome {
  max-width: 40rem;
  margin: 18vh auto 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.welcome-title {
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

.turn {
  margin-bottom: 1.6rem;
}

.user {
  display: flex;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  background: var(--panel);
}

.caret {
  color: var(--accent);
  font-weight: 600;
}

.user-text {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/*
 * Codex's own turn after Claude: no operator message, so a quieter header —
 * the same box as the implementation line above it, at the same edge.
 */
.user.review {
  /* The plan card's edge: `.items` padding plus a message's own. */
  margin-left: 1.3rem;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--muted);
}

.items {
  padding: 0.2rem 0 0 0.2rem;
}

.item {
  margin-top: 0.75rem;
}

/*
 * Prose reads with more air than the tool lines around it: a monospace face is
 * dense, and the conversation runs the whole width of the window.
 */
.message {
  padding-left: 1.1rem;
  line-height: 1.65;
}

.reasoning {
  padding-left: 1.1rem;
  line-height: 1.65;
  color: var(--muted);
  font-style: italic;
  white-space: pre-wrap;
}

.tool .head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.bullet {
  width: 0.6rem;
  color: var(--ok);
}

.tool.in_progress .bullet {
  color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.tool.failed .bullet {
  color: var(--error);
}

.verb {
  font-weight: 600;
}

.subject,
.command-text {
  min-width: 0;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.command-text {
  font-family: var(--mono);
}

.exit {
  color: var(--error);
  font-size: 0.85em;
}

.sub {
  padding-left: 1.1rem;
  color: var(--muted);
}

.todo.done {
  color: var(--faint);
  text-decoration: line-through;
}

details {
  margin: 0.2rem 0 0 1.1rem;
}

summary {
  color: var(--faint);
  cursor: pointer;
  list-style-position: outside;
}

summary:hover {
  color: var(--muted);
}

/*
 * A run of commands folded into one line. The summary is the same bullet,
 * verb and subject as any other tool line, followed by a chevron that turns
 * when it opens; inside, each command keeps its own output toggle.
 */
.command-group {
  margin: 0.75rem 0 0;
}

.command-group > summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  color: var(--text);
  list-style: none;
}

/* Quiet while folded, so the eye stays on the conversation; full on hover or open. */
.command-group > summary {
  opacity: 0.5;
  transition: opacity 120ms ease-out;
}

.command-group > summary:hover,
.command-group > summary:focus-visible,
.command-group[open] > summary {
  opacity: 1;
}

.command-group > summary::-webkit-details-marker {
  display: none;
}

.command-group > summary::after {
  content: '›';
  color: var(--faint);
  transition: transform 120ms ease-out;
}

.command-group[open] > summary::after {
  transform: rotate(90deg);
}

.command-group > summary:hover .subject,
.command-group > summary:hover::after {
  color: var(--text);
}

.group-current {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Open, the list below already shows the command in flight. */
.command-group[open] .group-current {
  display: none;
}

.group-body {
  margin: 0.15rem 0 0 0.3rem;
  padding-left: 0.8rem;
  border-left: 1px solid var(--border-soft);
}

.group-body > .item {
  margin-top: 0.5rem;
}

.output {
  max-height: 22rem;
  margin: 0.3rem 0 0;
  padding: 0.5rem 0.7rem;
  overflow: auto;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9em;
  white-space: pre;
}

.line.error,
.error {
  color: var(--error);
}

.turn-errors .line {
  margin-top: 0.5rem;
  padding-left: 1.1rem;
}

.turn-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.8rem;
  padding-left: 1.1rem;
  color: var(--faint);
  font-size: 0.88em;
}

.turn-foot > div,
.turn-foot > details {
  flex-basis: 100%;
}

.turn-foot details {
  margin-left: 0;
}

.turn-foot.running {
  color: var(--muted);
}

/* Air between the spinner and the words, as the Claude header has. */
.turn-foot .spinner {
  margin-right: 0.3rem;
}

.turn-foot.stopped,
.turn-foot.interrupted {
  color: var(--warn);
}

.spinner {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ---------------------------------------------------------- the composer */

.composer {
  position: relative;
  /* The same margin on all four sides, the operator's request. */
  padding: 1.25rem;
  border-top: 1px solid var(--border-soft);
}

/*
 * How much of the Codex plan is used: a two-pixel line drawn over the
 * composer's top border, from the left, as long as the fullest window is used.
 * The box around it is taller than the line so the tooltip can be reached; it
 * is centred on the border and takes no room.
 */
.usage {
  position: absolute;
  top: -5px;
  right: 0;
  left: 0;
  height: 9px;
}

.usage[hidden] {
  display: none;
}

.usage-fill {
  position: absolute;
  top: 3px;
  left: 0;
  width: 0;
  height: 2px;
  border-radius: 0 2px 2px 0;
  opacity: 0.85;
  transition:
    width 400ms ease-out,
    background-color 400ms ease-out;
}

.usage:hover .usage-fill {
  opacity: 1;
}

/*
 * The session's window, laid over the week's in the same place and thickness,
 * translucent and near-white (`sessionColor`), so it reads over the blue.
 */
.usage-session {
  opacity: 0.7;
}

.usage-session[hidden] {
  display: none;
}

.usage:hover .usage-session {
  opacity: 0.9;
}

.prompt-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.prompt-row:focus-within {
  border-color: var(--muted);
}

.attach {
  display: flex;
  align-items: center;
  align-self: center;
  padding: 0.25rem;
  border: 0;
  color: var(--muted);
}

.attach:hover:not(:disabled) {
  color: var(--text);
}

/* Images waiting to be sent, above the box they will go with. */
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.attachment {
  position: relative;
}

.attachment img {
  display: block;
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.attachment button {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  width: 1.3rem;
  height: 1.3rem;
  padding: 0;
  border-radius: 50%;
  background: var(--panel-raised);
  font-size: 0.75rem;
  line-height: 1;
}

/* Images a sent message carried, under its text. */
.user-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.user-images img {
  display: block;
  max-width: 14rem;
  max-height: 10rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: zoom-in;
}

.user-body {
  min-width: 0;
}

.composer.dragging .prompt-row {
  border-color: var(--accent);
}

/*
 * One line of text is shorter than the buttons beside it; centring it keeps the
 * same space above and below. Once it grows past them it is the tallest item,
 * centring does nothing, and the buttons stay on the bottom line as before.
 */
#prompt {
  flex: 1;
  align-self: center;
  min-width: 0;
  max-height: 40vh;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  line-height: 1.55;
}

#prompt::placeholder {
  color: var(--faint);
}

/* Model and effort: quiet beside Send until hovered, muted while unset. */
.composer-pick.picker-trigger {
  max-width: 14rem;
  padding: 0.2rem 0.45rem 0.2rem 0.6rem;
  border-color: transparent;
  background: transparent;
  font-size: 0.9em;
}

.composer-pick.picker-trigger:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--panel-raised);
}

.composer-pick.unset .picker-trigger-label {
  color: var(--muted);
}

#send.stop {
  border-color: var(--warn);
  color: var(--warn);
}

.composer-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.35rem;
  color: var(--faint);
  font-size: 0.8em;
}

.composer-foot .hint {
  margin-left: auto;
}

#status.error {
  color: var(--error);
}

/* ------------------------------------------------------- Markdown answers */

.md {
  white-space: normal;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md-paragraph {
  margin: 0 0 0.8em;
  white-space: pre-wrap;
  word-break: break-word;
}

.md-heading {
  margin: 1.4em 0 0.5em;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

h1.md-heading {
  font-size: 1.25em;
}

h2.md-heading {
  font-size: 1.15em;
}

h3.md-heading {
  font-size: 1.05em;
}

h4.md-heading,
h5.md-heading,
h6.md-heading {
  font-size: 1em;
  color: var(--muted);
}

.md-list {
  margin: 0.2em 0 0.9em;
  padding-left: 1.5em;
}

/*
 * A hanging indent: the marker sits in the margin, quieter than the words,
 * with a little air before them, and a wrapped line starts under the text.
 */
.md-list li {
  margin-bottom: 0.4em;
  padding-left: 0.3em;
  white-space: pre-wrap;
  word-break: break-word;
}

.md-list li::marker {
  color: var(--faint);
}

ol.md-list li::marker {
  font-size: 0.92em;
}

.md-list-tight li {
  margin-bottom: 0.2em;
}

.md-list .md-list {
  margin: 0.35em 0 0.2em;
}

.md-list li > .md-paragraph {
  margin-bottom: 0.35em;
}

.md-code-block {
  margin: 0.15em 0 0.9em;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.md-code-language {
  display: block;
  padding: 0.3rem 0.7rem 0;
  color: var(--faint);
  font-size: 0.75em;
}

/* Code scrolls sideways inside its own box; a wrapped line of code is a line
   that no longer says what it said. */
.md-code {
  margin: 0;
  padding: 0.5rem 0.75rem 0.6rem;
  overflow-x: auto;
  font-size: 0.92em;
  line-height: 1.5;
  white-space: pre;
}

.md-inline-code {
  padding: 0.05em 0.3em;
  border-radius: 3px;
  background: var(--panel-raised);
  font-size: 0.94em;
  word-break: break-word;
}

.md-link {
  color: var(--accent);
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  word-break: break-word;
}

.md-quote {
  margin: 0.15em 0 0.9em;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--border);
  color: var(--muted);
}

.md hr {
  margin: 1.4em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.md strong {
  font-weight: 600;
}

/*
 * The command picker: a trigger in the bar, and a launcher-style panel centred
 * near the top of the window, the way a system launcher opens. It is a modal
 * `<dialog>`, so it lives in the top layer above everything and needs no
 * z-index of its own.
 */
.picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 22rem;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  background: var(--panel);
}

.picker-trigger-caption {
  flex: none;
  margin-right: -0.15rem;
  color: var(--muted);
}

.picker-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-chevron {
  flex: none;
  width: 0.95em;
  height: 0.95em;
  color: var(--muted);
}

.picker {
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(34rem, 75vh);
  margin: 14vh auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgb(0 0 0 / 55%);
  /*
   * The layout lives here, not under [open]: while the panel fades out it has
   * already lost [open] but is still drawn (display is held until the fade
   * ends), and a column rule scoped to [open] would let the search, list and
   * foot spill into one row for that moment. `display` itself must stay under
   * [open] — set here, it would override the browser's hiding of a closed
   * dialog.
   */
  flex-direction: column;
  opacity: 0;
  transition:
    opacity 140ms ease-out,
    display 140ms allow-discrete,
    overlay 140ms allow-discrete;
}

.picker[open] {
  display: flex;
  opacity: 1;
}

@starting-style {
  .picker[open] {
    opacity: 0;
  }
}

/* Dialogs fade out as they fade in, and their backdrop with them. */
.picker::backdrop,
.confirm::backdrop {
  background: rgb(0 0 0 / 0%);
  transition:
    background 140ms ease-out,
    display 140ms allow-discrete,
    overlay 140ms allow-discrete;
}

.picker[open]::backdrop,
.confirm[open]::backdrop {
  background: rgb(0 0 0 / 45%);
}

@starting-style {
  .picker[open]::backdrop,
  .confirm[open]::backdrop {
    background: rgb(0 0 0 / 0%);
  }
}

.picker-search {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--border-soft);
}

.picker-search-icon {
  flex: none;
  width: 1.2em;
  height: 1.2em;
  color: var(--muted);
}

.picker-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 1.1em;
  color: var(--text);
}

.picker-input::placeholder {
  color: var(--faint);
}

.picker-list {
  flex: 1;
  min-height: 0;
  padding: 0.4rem;
  overflow-y: auto;
}

.picker-group {
  padding: 0.6rem 0.65rem 0.35rem;
  color: var(--muted);
  font-size: 0.8em;
  font-weight: 600;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}

.picker-item.active {
  background: var(--panel-raised);
}

.picker-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-label mark {
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.picker-meta {
  flex: none;
  color: var(--faint);
  font-size: 0.85em;
}

.picker-check {
  flex: none;
  width: 1em;
  height: 1em;
  color: var(--accent);
}

/*
 * A keycap, wherever one is drawn: raised by a heavier bottom edge, the way a
 * physical key reads.
 */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.65em;
  height: 1.65em;
  padding: 0 0.35em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8em;
  line-height: 1;
}

.picker-item.active .picker-key {
  border-color: var(--muted);
  color: var(--text);
}

/* Out of play once something is typed: the space stays, so rows do not shift. */
.picker-key.idle {
  visibility: hidden;
}

.picker-empty {
  padding: 1.4rem 0.65rem;
  color: var(--faint);
  text-align: center;
}

.picker-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  padding: 0.55rem 1.1rem;
  border-top: 1px solid var(--border-soft);
  color: var(--faint);
  font-size: 0.78em;
}

.picker-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.picker-foot kbd {
  min-width: 1.4em;
  height: 1.4em;
  font-size: 0.95em;
}

/*
 * The confirmation: a small card centred in the window, the same surface as the
 * picker, with its title set off by a hairline, the main answer centred below
 * and the other at the right, each with the key that gives it.
 */
.confirm {
  width: min(38rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgb(0 0 0 / 55%);
  opacity: 0;
  transform: scale(0.97);
  transition:
    opacity 140ms ease-out,
    transform 140ms ease-out,
    display 140ms allow-discrete,
    overlay 140ms allow-discrete;
}

.confirm[open] {
  opacity: 1;
  transform: none;
}

@starting-style {
  .confirm[open] {
    opacity: 0;
    transform: scale(0.97);
  }
}

.confirm-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.25rem 1.25rem 1rem;
}

.confirm-title {
  /* A hairline under the title, so the question reads apart from its body. */
  margin: 0 0 0.2rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 1.05em;
  font-weight: 600;
}

.confirm-body p {
  margin: 0;
}

.confirm-body .confirm-subject {
  margin-bottom: 0.4rem;
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 600;
}

.confirm-message {
  color: var(--muted);
  font-size: 0.92em;
  line-height: 1.5;
}

/*
 * Every dialog's answers: the main action in the centre of the card, and the
 * other one at the far right. Three columns, the outer two equal, so the middle
 * is the centre whatever sits beside it.
 */
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.confirm-actions > .confirm-ok {
  grid-column: 2;
}

.confirm-actions > :not(.confirm-ok) {
  grid-column: 3;
  justify-self: end;
}

/* The other answer is quiet: muted words and no box, until it is hovered. */
.confirm-cancel {
  border-color: transparent;
  color: var(--muted);
}

.confirm-cancel:hover:not(:disabled) {
  border-color: var(--muted);
  color: var(--text);
}

.confirm-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.6rem 0.4rem 0.8rem;
  border-radius: 8px;
}

.confirm-actions kbd {
  height: 1.5em;
  font-size: 0.72em;
}

.confirm-ok {
  border-color: var(--muted);
  background: var(--panel-raised);
}

.confirm-ok.danger {
  border-color: rgb(255 143 143 / 45%);
  background: rgb(255 143 143 / 12%);
  color: var(--error);
}

.confirm-ok.danger:hover:not(:disabled) {
  border-color: var(--error);
  background: rgb(255 143 143 / 18%);
}

.confirm-ok.danger kbd {
  border-color: rgb(255 143 143 / 35%);
  color: var(--error);
}

/*
 * The project profile: the confirmation's card, wider, holding a list of names
 * and values. Each value keeps its own Copy (and Open, for an address) at the
 * end of its line; a long value wraps rather than widening the card.
 */
.confirm.profile {
  width: min(52rem, calc(100vw - 2rem));
}

/*
 * Each value sits right after its own name, with the same small gap on every
 * row and no shared column: a short name is not padded out to a long one.
 */
.profile-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding: 0.35rem 0;
}

.profile-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.profile-row.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.profile-key {
  flex: none;
  max-width: 14rem;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.9em;
}

.profile-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
}

/*
 * A value stays on one line: the card is wide enough for an ordinary URL, and
 * one longer than that is cut with an ellipsis rather than wrapped. Copy still
 * takes the whole value.
 */
.profile-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-text.multiline {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.profile-link {
  color: var(--accent);
  text-decoration: none;
}

.profile-link:hover {
  text-decoration: underline;
}

.profile-copy {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  border-color: transparent;
  color: var(--faint);
}

.profile-copy:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text);
}

.profile-copy.copied {
  color: var(--ok);
}

.profile-copy.failed {
  color: var(--error);
}

.profile-note.error {
  color: var(--error);
}

/* An empty value, such as a project that is not published: faint. */
.profile-text.none {
  color: var(--faint);
}

/* The note about the file closes the list, small and faint. */
.confirm.profile .profile-note:not(.error) {
  color: var(--faint);
  font-size: 0.82em;
}

/*
 * New project: the same card, holding a small form. Labels sit in a column on
 * the left like the profile's names; the GitHub address is text, not a field,
 * because it is derived and never typed.
 */
.confirm.new-project {
  width: min(44rem, calc(100vw - 2rem));
}

.new-project-fields {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.new-project-field {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.9rem;
  align-items: baseline;
}

.new-project-label {
  color: var(--muted);
  font-size: 0.9em;
}

.new-project-input {
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea.new-project-input {
  resize: vertical;
}

.new-project-input:focus {
  border-color: var(--muted);
  outline: none;
}

.new-project-input:disabled {
  opacity: 0.45;
}

.new-project-github {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-project-note:empty {
  display: none;
}

.new-project-note.error {
  color: var(--error);
}

.new-project-note.working {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Quiet until hovered, then the colour of danger. */
.profile-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-color: transparent;
  color: var(--muted);
  border-radius: 8px;
}

.profile-delete[hidden] {
  display: none;
}

.profile-delete:hover:not(:disabled) {
  border-color: rgb(255 143 143 / 45%);
  color: var(--error);
}

/*
 * Delete project: the confirmation's card, a little wider, with one box for
 * the folder and, under it while ticked, what would be lost and the name to
 * type.
 */
.confirm.remove-project {
  width: min(44rem, calc(100vw - 2rem));
}

.remove-project-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.remove-project-option input {
  margin: 0;
  accent-color: var(--error);
}

.remove-project-option:has(input:disabled) {
  opacity: 0.45;
  cursor: default;
}

.remove-project-folder-name {
  color: var(--text);
}

.remove-project-reason {
  margin: -0.4rem 0 0 1.6rem;
}

.remove-project-loss {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgb(255 143 143 / 30%);
  border-radius: var(--radius);
  background: rgb(255 143 143 / 6%);
}

.remove-project-loss[hidden] {
  display: none;
}

.remove-project-loss-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.92em;
}

/* Colour carries the meaning: amber for work that would go, green for none. */
.remove-project-loss-list .loss-loss {
  color: var(--warn);
}

.remove-project-loss-list .loss-safe {
  color: var(--ok);
}

.remove-project-loss-list .loss-note {
  color: var(--muted);
}

/*
 * A plan for Claude: the fenced block Codex wrote, drawn as a card — accent
 * edge, a header that says what it is, and the plan as the Markdown it is.
 */
.plan-card {
  margin: 0.4em 0 0.9em;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}

.plan-card-head {
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--accent);
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.plan-card-body {
  max-height: 28rem;
  padding: 0.6rem 0.9rem 0.2rem;
  overflow-y: auto;
}

/* The plan's two answers, under the turn that holds it. */
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.2rem 0 0.4rem 1.1rem;
}

.plan-actions button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.8rem 0.4rem 0.5rem;
  border-radius: 8px;
}

.plan-actions kbd {
  height: 1.5em;
  font-size: 0.72em;
}

.plan-implement {
  border-color: var(--accent);
  background: rgb(124 183 255 / 12%);
  color: var(--text);
}

.plan-implement:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgb(124 183 255 / 20%);
}

.plan-change {
  border-color: transparent;
  color: var(--muted);
}

/* Within reach but not waiting: one quiet button, the prompt stays free. */
.plan-actions.quiet .plan-implement {
  padding-left: 0.8rem;
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
}

.plan-actions.quiet .plan-implement:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
}

.plan-change:hover:not(:disabled) {
  border-color: var(--muted);
  color: var(--text);
}

/*
 * Ship and the preview, after Claude's newest work. The preview is a link
 * (it opens the app in a new tab) drawn as the quiet button beside Ship.
 */
.ship-actions {
  margin-top: 0.6rem;
}

.ship-actions .preview-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.ship-actions .preview-link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.ship-actions svg {
  flex: none;
  opacity: 0.8;
}

/*
 * One implementation: Claude's run, between the plan and its review. A header
 * like a turn's foot, the actions folded under one line once Claude is done,
 * the question it waits on, and its report.
 */
.claude {
  /* Aligned with the plan card it implements, as the review below it is. */
  margin: 0.2rem 0 1.6rem 1.3rem;
  padding: 0.6rem 0.8rem 0.4rem;
  border: 1px solid rgb(217 119 87 / 35%);
  border-radius: var(--radius);
}

.claude .workflow-mark {
  color: var(--claude);
}

.claude .spinner {
  border-top-color: var(--claude);
  border-right-color: var(--claude);
}

/* What Claude is doing, in Claude's colour, as a task's title before it. */
.claude-state {
  color: var(--claude);
}

/* What Codex's review said of it, in Codex's. */
.claude-verdict {
  color: var(--accent);
}

.claude-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.claude-meta {
  color: var(--faint);
  font-size: 0.88em;
}

.claude-actions {
  margin-top: 0.35rem;
}

/* Earlier attempts at the same plan: one quiet line each, under the header. */
.claude-history {
  margin-top: 0.2rem;
  color: var(--faint);
  font-size: 0.85em;
}

/* Try again, inside the box, under the ending that called for it. */
.claude-plan-actions {
  margin-top: 0.6rem;
}

.claude-plan-actions .plan-actions {
  margin: 0;
}

.claude-actions-summary {
  width: fit-content;
  color: var(--muted);
  font-size: 0.88em;
  cursor: pointer;
}

.claude-actions-summary:hover {
  color: var(--text);
}

.claude-report {
  margin-top: 0.35rem;
}

/* Folded like the actions, with the accent so the answer is found first. */
.claude-report-head {
  width: fit-content;
  color: var(--claude);
  font-size: 0.88em;
  cursor: pointer;
}

.claude-report-body {
  margin-top: 0.4rem;
  padding: 0.5rem 0 0 1rem;
  border-top: 1px solid var(--border-soft);
}

.lines-added {
  color: var(--ok);
}

.lines-removed {
  color: var(--error);
}

/* The question Claude is waiting on: amber, so the wait is seen. */
.claude-question {
  margin-top: 0.7rem;
}

.question-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgb(255 201 120 / 45%);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: rgb(255 201 120 / 6%);
}

.question-card-head {
  color: var(--warn);
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.question-header {
  color: var(--muted);
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.question-text {
  margin: 0.15rem 0 0.5rem;
}

.question-hint {
  margin: -0.3rem 0 0.5rem;
  color: var(--faint);
  font-size: 0.85em;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.question-option {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-color: var(--border-soft);
  border-radius: 8px;
  text-align: left;
}

.question-option.chosen {
  border-color: var(--warn);
  background: rgb(255 201 120 / 12%);
}

.question-option kbd {
  flex: none;
  height: 1.5em;
  font-size: 0.72em;
}

.question-option-words {
  display: flex;
  flex-direction: column;
}

.question-option-description {
  color: var(--muted);
  font-size: 0.88em;
}

.question-foot {
  display: flex;
  justify-content: flex-end;
}

.question-send {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.8rem 0.4rem 0.5rem;
  border-color: var(--warn);
  border-radius: 8px;
}

.question-send kbd {
  height: 1.5em;
  font-size: 0.72em;
}

.workflow-mark {
  color: var(--accent);
  font-size: 0.8em;
}

.workflow-detail {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.9em;
}

.workflow-detail.error {
  color: var(--error);
}

/*
 * The `@task` menu: a list over the composer, as wide as it, the highlighted row
 * in the accent. Its own box, so it sits above the prompt without moving it.
 */
/*
 * Above everything on the page — the usage line drawn over the composer's
 * border, the conversation behind it — though under any `<dialog>`, which
 * lives in the top layer.
 */
.task-menu {
  position: absolute;
  z-index: 50;
  right: 1.25rem;
  bottom: calc(100% - 0.6rem);
  left: 1.25rem;
  display: flex;
  flex-direction: column;
  max-height: 16rem;
  padding: 0.3rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 12px 32px rgb(0 0 0 / 45%);
}

.task-menu[hidden] {
  display: none;
}

.task-option {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-color: transparent;
  border-radius: 6px;
  text-align: left;
}

.task-option.active {
  background: var(--panel-raised);
}

.task-option-key {
  flex: none;
  align-self: center;
  height: 1.5em;
  font-size: 0.72em;
}

/* Out of play once something is typed: the space stays, so rows do not shift. */
.task-option-key.idle {
  visibility: hidden;
}

.task-option-label {
  color: var(--accent);
}

.task-option-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* `@task add`: the form's instruction gets room, and the name its hint. */
.confirm.task-form {
  width: min(48rem, calc(100vw - 2rem));
}

.task-form-prompt {
  min-height: 9rem;
}

.task-form-hint {
  margin-top: 0.3rem;
  color: var(--faint);
  font-size: 0.85em;
}

/* A run launched with `@task`: its task's title leads the header, in Claude's colour. */
.claude-task-title {
  color: var(--claude);
  font-weight: 600;
}

/* Under a message that proposed a profile: one quiet button per proposal. */
.profile-proposal {
  margin-top: 0.6rem;
}

.profile-apply {
  padding: 0.3rem 0.7rem;
  border-color: var(--border);
  background: var(--panel-raised);
  color: var(--accent);
  font-size: 0.9em;
}

.profile-apply:hover:not(:disabled) {
  border-color: var(--accent);
}

/*
 * The pointer sparkles: one layer, and the motes inside it.
 *
 * `pointer-events: none` is the whole safety of this feature — every control is
 * drawn under the layer and must go on receiving hover, focus and clicks — and
 * `overflow: hidden` is the other half: a mote drifts away from where it was
 * born, and one born near an edge must not add to anything's scrollable width.
 * Nothing here sets `cursor`: the operator's own pointer is untouched. The
 * layer sits under any `<dialog>`, which lives in the top layer.
 *
 * Position, size, colour, glow and the whole animation are per-mote and are
 * written by `bindCursorSparkles` from `SPARKLE_TUNING`; what is left is shape.
 */
.cursor-sparkles {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.cursor-sparkle {
  position: absolute;
  border-radius: 50%;
  /* The starting frame sets this too, so a mote never paints unanimated at full
     strength for the one frame between being appended and being animated. */
  opacity: 0;
  will-change: transform, opacity;
}

/* Too narrow for three columns: the bar wraps, actions to the right. */
@media (max-width: 900px) {
  .bar {
    display: flex;
    flex-wrap: wrap;
  }

  .bar-actions {
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .composer-foot .hint {
    display: none;
  }
}
