:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #1f1d1a;
  --muted: #6b665e;
  --line: #ddd8ce;
  --accent: #2f5d50;
  --on-accent: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --fg: #ebe7df;
    --muted: #a09a8f;
    --line: #37342f;
    --accent: #8fc7b3;
    --on-accent: #10201b;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.6 Georgia, "Iowan Old Style", serif;
}
main { max-width: 42rem; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
h1 { font-size: 1.6rem; margin: 0.5rem 0; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
section { margin-top: 1.5rem; }
a { color: var(--accent); }
label { display: block; margin: 1rem 0 0.3rem; font: 0.9rem system-ui, sans-serif; color: var(--muted); }
input[type="file"], textarea {
  width: 100%;
  padding: 0.6rem;
  font: 1rem system-ui, sans-serif;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
button, .button {
  display: inline-block;
  padding: 0.6rem 1rem;
  font: 600 0.95rem system-ui, sans-serif;
  color: var(--on-accent);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
}
button.quiet { color: var(--accent); background: transparent; border-color: var(--line); }
button:disabled { opacity: 0.5; cursor: default; }
progress { width: 100%; margin-top: 1rem; accent-color: var(--accent); }
#status { min-height: 1.6em; font: 0.95rem system-ui, sans-serif; color: var(--muted); overflow-wrap: anywhere; }
article h1 { font-size: 1.5rem; line-height: 1.3; }
article h2 { padding-top: 1rem; border-top: 1px solid var(--line); }
article li { margin: 0.3rem 0; }
pre, code { font: 0.9em ui-monospace, monospace; }
pre { overflow-x: auto; padding: 0.8rem; border: 1px solid var(--line); border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--line); }
.question { margin: 1rem 0; }
.question p { margin: 0 0 0.3rem; }
details.note { margin-top: 1rem; }
details.note summary { font: 0.9rem system-ui, sans-serif; color: var(--muted); cursor: pointer; }
details.note textarea { margin-top: 0.4rem; }
#saved { font: 0.95rem system-ui, sans-serif; color: var(--muted); }

/* The app shell */
#sync, .hint { font: 0.85rem system-ui, sans-serif; color: var(--muted); }
.modes { display: flex; gap: 0; margin: 0.5rem 0 1rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.modes button { flex: 1; border: 0; border-radius: 0; color: var(--fg); background: transparent; }
.modes button[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); }
#signin { padding: 0.8rem; border: 1px solid var(--line); border-radius: 6px; font: 0.95rem system-ui, sans-serif; }
#text { font: inherit; line-height: 1.6; resize: vertical; }
#editing { margin: 0 0 0.3rem; font: 0.85rem system-ui, sans-serif; color: var(--muted); }
#search { width: 100%; margin-top: 2rem; padding: 0.6rem; font: 1rem system-ui, sans-serif; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.thumbs figure { margin: 0; }
.thumbs img { display: block; width: 6.5rem; height: 6.5rem; object-fit: cover; border-radius: 6px; background: var(--line); }
.thumbs .remove { width: 100%; margin-top: 0.2rem; padding: 0.2rem; font-size: 0.8rem; }
.entry { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.entry.open { background: rgba(127, 127, 127, 0.1); }
.entry h3 { margin: 0 0 0.3rem; font: 600 0.85rem system-ui, sans-serif; color: var(--muted); }
.entry p { margin: 0 0 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry button, #more { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
#more { margin-top: 1rem; }
#messages { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1rem; }
.message { max-width: 92%; padding: 0.6rem 0.8rem; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; color: var(--on-accent); background: var(--accent); font: 1rem/1.5 system-ui, sans-serif; }
.message.assistant { align-self: flex-start; border: 1px solid var(--line); }
.message.waiting { color: var(--muted); }
.message.failed { border-color: #b3261e; }
.signout { margin-top: 3rem; }

/* Journal */
.filters { display: flex; gap: 0.5rem; margin-top: 2rem; }
.filters #search { flex: 1; margin-top: 0; }
.filters #month, select { padding: 0.5rem; font: 0.95rem system-ui, sans-serif; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 6px; }
#details { margin-top: 0.6rem; }
#details summary { font: 0.9rem system-ui, sans-serif; color: var(--muted); cursor: pointer; }
#details input { width: 100%; padding: 0.5rem; font: 1rem system-ui, sans-serif; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.entry .meta { margin: 0 0 0.4rem; font: 0.8rem system-ui, sans-serif; color: var(--muted); white-space: normal; }
.entry .body { margin: 0 0 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry .actions { margin-top: 0.5rem; }
#count { margin: 0.5rem 0 0; }

label.check { display: flex; align-items: center; gap: 0.5rem; color: inherit; font-size: 1rem; }
label.check input { width: auto; margin: 0; }
#journal { display: block; }
.chips { display: flex; gap: 0.4rem; margin-top: 2rem; padding-bottom: 0.3rem; overflow-x: auto; }
.chips + .filters { margin-top: 0.6rem; }
.chip { flex: none; padding: 0.35rem 0.7rem; font: 0.9rem system-ui, sans-serif; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 999px; }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip small { color: var(--muted); }
.dot { display: inline-block; width: 0.7rem; height: 0.7rem; margin-right: 0.4rem; border-radius: 50%; vertical-align: baseline; }
.entry { padding-left: 0.7rem; }
.entry h3 input { width: auto; margin: 0 0.3rem 0 0; }
#bulk { align-items: center; flex-wrap: wrap; }
.rows { padding: 0; list-style: none; }
.rows li { display: flex; align-items: center; gap: 0.4rem; margin: 0.4rem 0; }
.rows .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows small { color: var(--muted); font: 0.8rem system-ui, sans-serif; }
.rows button { padding: 0.3rem 0.6rem; }
.panel { margin-top: 1rem; padding: 0.2rem 0.9rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; }
.panel input[type="text"] { width: 100%; padding: 0.6rem; font: 1rem system-ui, sans-serif; color: inherit; background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch { width: 2rem; height: 2rem; padding: 0; border: 2px solid transparent; border-radius: 50%; }
.swatch[aria-pressed="true"] { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg) inset; }
#favorites[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.panel select { margin-top: 0.8rem; }
