/**
 * One column of prompts on a quiet page.
 *
 * Same palette as todo/: everything that is not something you wrote — the
 * connection, the counts, the dates — sits a step back, so the text at full
 * strength is your own. Borders are hairlines at ~9% of the text colour rather
 * than grey, which keeps them quiet in dark mode too.
 *
 * Two controls are drawn louder than the rest, on purpose: the compose box,
 * because catching the idea is why the page is opened on a phone, and the Copy
 * button, because handing it back is why it is opened at the desk.
 */
:root {
  color-scheme: light dark;

  --page: #f7f7f5;
  --panel: #ffffff;
  --text: #37352f;
  --muted: #73716c;
  --faint: #91908c;
  --line: rgba(55, 53, 47, 0.09);
  --border: rgba(55, 53, 47, 0.19);
  --active: rgba(55, 53, 47, 0.08);
  --accent: #2383e2;
  --danger: #c4554d;
  --ok: #448361;
  --pending: #b7791f;
  --shadow: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1),
    0 9px 24px rgba(15, 15, 15, 0.2);

  --column: 720px;
  --gutter: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #191919;
    --panel: #202020;
    --text: rgba(255, 255, 255, 0.81);
    --muted: rgba(255, 255, 255, 0.53);
    --faint: rgba(255, 255, 255, 0.4);
    --line: rgba(255, 255, 255, 0.094);
    --border: rgba(255, 255, 255, 0.2);
    --active: rgba(255, 255, 255, 0.08);
    --accent: #4a9eff;
    --danger: #ff7369;
    --ok: #529e72;
    --pending: #e0a84a;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 3px 6px rgba(0, 0, 0, 0.35),
      0 9px 24px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%; /* iOS otherwise inflates text in landscape */
}

body {
  background: var(--page);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
textarea {
  font: inherit;
}

::selection {
  background: rgba(35, 131, 226, 0.28);
}

.hidden {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
 * Layout
 * ------------------------------------------------------------------ */

.bar {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  min-height: 34px;
  padding: 10px 14px 0;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-right: calc(14px + env(safe-area-inset-right, 0px));
}

.doc {
  margin: 0 auto;
  max-width: var(--column);
  padding: 0 var(--gutter) 48px;
  padding-right: calc(var(--gutter) + env(safe-area-inset-right, 0px));
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  padding-left: calc(var(--gutter) + env(safe-area-inset-left, 0px));
}

.doc__head {
  padding-bottom: 16px;
}

.doc__title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 8px 0 0;
}

.doc__stat {
  color: var(--faint);
  font-size: 13px;
  margin: 6px 0 0;
  min-height: 1.5em; /* holds its line while empty, so nothing jumps on first load */
}

/* ------------------------------------------------------------------ *
 * Status
 * ------------------------------------------------------------------ */

.status {
  color: var(--faint);
  font-size: 12px;
}

/* Pulsing dot: the realtime stream is connected. The text stays faint — a live
   connection is the ordinary case and only needs to be checkable. */
.status--live::before {
  animation: pulse 2s ease-in-out infinite;
  background: var(--ok);
  border-radius: 50%;
  content: '';
  display: inline-block;
  height: 6px;
  margin-right: 5px;
  width: 6px;
}

.status--pending {
  color: var(--pending);
}

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

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.btn {
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  min-height: 32px;
  padding: 4px 10px;
  touch-action: manipulation;
  transition: background 20ms ease-in, color 20ms ease-in, opacity 120ms ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover,
.btn:active {
  background: var(--active);
  color: var(--text);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Inverted: the text colour as fill, the card colour as text. It follows the
   theme without a second set of values, and nothing else on the page is
   filled, so it cannot be mistaken for anything but the thing to press. */
.btn--primary,
.btn--primary:hover,
.btn--primary:active {
  background: var(--text);
  color: var(--panel);
  font-weight: 600;
  padding: 4px 16px;
}

.btn--primary:hover {
  opacity: 0.86;
}

.btn--primary:disabled {
  cursor: default;
  opacity: 0.3;
}

.btn--done,
.btn--done:hover {
  background: var(--ok);
  color: #fff;
  opacity: 1;
}

.btn--danger,
.btn--danger:hover,
.btn--danger:active {
  background: var(--danger);
  color: #fff;
}

/* ------------------------------------------------------------------ *
 * Compose
 * ------------------------------------------------------------------ */

/* The one outline on the page with weight to it, and the one that turns blue
   while you are typing in it. */
.compose {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 120ms ease;
}

.compose:focus-within {
  border-color: var(--accent);
}

.compose__body {
  background: none;
  border: 0;
  color: var(--text);
  display: block;
  /* 16px is a floor, not a preference: iOS zooms the page in on focus for
     anything smaller, and never zooms back out. */
  font-size: 16px;
  outline: none;
  padding: 0 16px;
  width: 100%;
}

.compose__body {
  line-height: 1.55;
  max-height: 60vh;
  max-height: 60dvh;
  min-height: 92px;
  padding-bottom: 8px;
  padding-top: 10px;
  resize: none; /* the height is autosize()'s job */
}

.compose__body::placeholder {
  color: var(--faint);
  font-weight: 400;
}

.compose__foot {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 6px 8px 8px 16px;
}

.compose__hint {
  color: var(--faint);
  font-size: 12px;
}

.compose__hint--over {
  color: var(--danger);
}

/* ------------------------------------------------------------------ *
 * Search
 * ------------------------------------------------------------------ */

.search {
  margin-top: 28px;
}

.search__input {
  background: var(--active);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  padding: 8px 12px;
  transition: border-color 120ms ease, background 120ms ease;
  width: 100%;
}

.search__input:focus {
  background: var(--panel);
  border-color: var(--accent);
}

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

/* ------------------------------------------------------------------ *
 * Prompts
 * ------------------------------------------------------------------ */

.prompts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

/* Without a search box above it the list needs its own distance from the
   compose box, or the first card reads as part of the form. */
.search.hidden + .prompts {
  margin-top: 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 10px;
}

/* Prompt text is always editable, styled like the surrounding document.
   Focusing it keeps the same typography, spacing, and dimensions. */
.card__body {
  appearance: none;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--text);
  display: block;
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  min-height: 1.6em;
  outline: none;
  overflow-wrap: anywhere;
  padding: 0;
  resize: none;
  white-space: pre-wrap;
  width: 100%;
}

.card__body--clamped {
  max-height: 12.8em;
  overflow-y: auto;
}

.card__notice {
  color: var(--pending);
  font-size: 12px;
}

.card__notice--error {
  color: var(--danger);
}

.card__more {
  color: var(--accent);
  font-size: 13px;
  margin: 2px 0 0 -10px;
  min-height: 28px;
}

.card__more:hover {
  color: var(--accent);
}

.card__foot {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  justify-content: space-between;
  margin-top: 10px;
}

.card__actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Waiting for a signal: still a card, still copyable, but its edge is dashed
   and amber so it reads as not-yet-everywhere. */
.card--pending {
  border-color: var(--pending);
  border-style: dashed;
}

.card--error {
  border-color: var(--danger);
}

.empty {
  color: var(--faint);
  font-size: 14px;
  margin: 28px 0 0;
  text-align: center;
}

/* ------------------------------------------------------------------ *
 * Toast — at the top, where the keyboard cannot cover it.
 * ------------------------------------------------------------------ */

.toast {
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  left: 50%;
  max-width: calc(100% - 32px);
  opacity: 0;
  padding: 8px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 10;
}

.toast--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ *
 * Narrow screens and touch
 * ------------------------------------------------------------------ */

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
  }

  .doc__title {
    font-size: 32px;
  }
}

/* A thumb needs a bigger target than a cursor does. */
@media (hover: none) {
  .btn {
    min-height: 38px;
  }

  .btn--primary {
    padding: 4px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }

  .status--live::before {
    animation: none;
  }
}
