/* Undiary: hand-written CSS, no build step. Colors declared once with
   light-dark(); the browser and OS do the theming. */

:root {
  color-scheme: light dark;
  --bg:     light-dark(#faf9f7, #101216);
  --panel:  light-dark(#ffffff, #171a20);
  --text:   light-dark(#1f2328, #e8eaed);
  --muted:  light-dark(#5f6368, #9aa0a6);
  --border: light-dark(#e4e2dd, #2a2f38);
  --accent: light-dark(#1a73e8, #8ab4f8);
  --accent-wash: light-dark(rgba(26, 115, 232, 0.07), rgba(138, 180, 248, 0.09));
  --danger: light-dark(#c5221f, #f28b82);
  --star: light-dark(#e5a300, #ffd257);
  --flash: light-dark(rgba(26, 115, 232, 0.16), rgba(138, 180, 248, 0.22));
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--accent); }

.quiet {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}
.quiet:hover { color: var(--accent); }

/* Signed-in identity, upper right: an avatar with a small menu. */
.who { position: relative; }

.who-btn {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  overflow: hidden;
  cursor: pointer;
}
.who-btn:hover { border-color: var(--accent); }
.who-avatar { width: 100%; height: 100%; object-fit: cover; }
.who-fallback {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  user-select: none;
}

/* Shared popover card; each site of use positions it. */
.popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 30;
  padding: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
}
.popover .menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: none;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.popover .menu-item:hover { background: var(--accent-wash); color: var(--accent); }
.popover .menu-danger:hover { background: var(--accent-wash); color: var(--danger); }
.popover form { margin: 0; }

.who-menu { min-width: 15rem; }
.who-version {
  margin: 0.15rem 0 0;
  padding: 0.3rem 0.7rem 0.35rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  cursor: default;
}
.who-email {
  margin: 0;
  padding: 0.5rem 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

/* ---- Audio recording ---- */

.rec-btn {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.rec-btn:hover { border-color: var(--accent); color: var(--accent); }
/* The two icons swap via the recording state; hidden attrs don't
   apply to inline SVG. */
.rec-btn .rec-icon-stop { display: none; }
.rec-btn[data-recording] .rec-icon-mic { display: none; }
.rec-btn[data-recording] .rec-icon-stop { display: block; }
.rec-btn[data-recording] {
  border-color: var(--danger);
  color: var(--danger);
  animation: rec-pulse 1.6s ease-in-out infinite;
}
@keyframes rec-pulse {
  50% { box-shadow: 0 0 0 5px var(--accent-wash); }
}
@media (prefers-reduced-motion: reduce) {
  .rec-btn[data-recording] { animation: none; }
}

.rec-status {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

/* Five bars that move only for an actual voice. */
.rec-level {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 1.2rem;
}
.rec-level i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: var(--border);
  transform: scaleY(0.18);
  transform-origin: center;
  transition: transform 90ms linear, background 150ms;
}
.rec-level[data-hearing] i { background: var(--danger); }
.rec-preview { width: 13rem; height: 2.1rem; }

.mic-select {
  max-width: 11rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-link {
  color: var(--muted);
  text-decoration: none;
}
.entry-link:hover { color: var(--accent); }

.star-mark {
  color: var(--star);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
  vertical-align: -0.12em;
}
.star-mark:hover {
  text-decoration: none;
  filter: brightness(1.12);
}

.entry-detail { border-bottom: 1px solid var(--border); }

.back-link { margin-top: 1.5rem; font-size: 0.95rem; }
.rec-status[data-attached] { color: var(--text); }

.rec-discard {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.rec-discard:hover { color: var(--danger); }

.log-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
  min-width: 0;
}

.entry-audio { margin-top: 0.4rem; }
.entry-audio audio { width: 100%; max-width: 24rem; height: 2.2rem; }
.pending-note {
  display: inline-block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.tag-chip {
  padding: 0.08rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  text-decoration: none;
}
a.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.tag-watched {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent);
}

/* Provenance chip: this note fed that todo. */
.todo-ref {
  padding: 0.08rem 0.55rem;
  border: 1px dashed var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  text-decoration: none;
}
.todo-ref:hover { color: var(--accent); border-color: var(--accent); }

.entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.entry-actions { position: relative; }
.dots-btn {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.dots-btn:hover { background: var(--accent-wash); color: var(--accent); }

/* ---- The log form ---- */

.log-form { padding-top: 1.5rem; }

.log-meta {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
}

.log-meta input[type="date"] {
  border: 0;
  background: none;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  padding: 0;
}

.log-clock {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.log-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.6rem;
}

button[type="submit"], .btn {
  display: inline-block;
  padding: 0.45rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
button[type="submit"]:hover, .btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Tabs ---- */

.tabs {
  display: flex;
  gap: 1.4rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.65rem 1.25rem 0;
}
.tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid transparent;
}
.tabs a.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.tabs a:hover { color: var(--accent); }

/* ---- Todos ---- */

.todo-add {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.4rem;
}
.todo-add input[type="text"] {
  flex: 1;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.todo-add input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.todo-search { margin-top: 0.7rem; }

.todo-fold {
  border-top: 1px solid var(--border);
  padding: 0.15rem 0;
}
.todo-fold summary {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.55rem 0;
  cursor: pointer;
  list-style: none;
}
.todo-fold summary::-webkit-details-marker { display: none; }
.todo-fold summary::before {
  content: "\25B8";
  color: var(--muted);
  font-size: 0.8rem;
}
.todo-fold[open] > summary::before { content: "\25BE"; }
.fold-title { font-weight: 600; }
.fold-count {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.02rem 0.5rem;
}

.todo-thought {
  margin: 0.35rem 0 0;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}
.todo-thought a {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  text-decoration: none;
}
.todo-thought a:hover { color: var(--accent); }

.item-add { margin-top: 0.3rem; }
.item-add summary {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.item-add summary::-webkit-details-marker { display: none; }
.item-add summary::before {
  content: "+";
  font-size: 0.95rem;
  line-height: 1;
}
.item-add summary:hover { color: var(--accent); border-color: var(--accent); }
.item-add[open] summary { color: var(--accent); border-color: var(--accent); }
.item-add form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.item-add input[type="text"] {
  flex: 1;
  max-width: 24rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.todo-addnote { margin-top: 0.45rem; }
.todo-addnote summary {
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.todo-addnote form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.todo-addnote textarea {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

.todo-section { margin-top: 1.6rem; }
.todo-section h2 { font-size: 1.05rem; margin: 0 0 0.4rem; }
.horizon-label {
  margin: 0.9rem 0 0.2rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}
.todo {
  padding: 0.8rem 0;
  border-top: 1px solid var(--border);
}
.todo-done { opacity: 0.65; }

/* The exit: collapse in place so the list below glides up. */
.todo-leaving {
  overflow: hidden;
  opacity: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  border-top-width: 0 !important;
  transition: height 260ms ease, opacity 180ms ease,
    padding 260ms ease, border-top-width 260ms ease;
}
.todo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.todo-title { margin: 0; font-size: 1rem; }
.todo-controls { display: flex; align-items: center; gap: 0.6rem; }
.todo-controls form { margin: 0; }
.todo-summary { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.92rem; }
.todo-evidence {
  margin: 0.3rem 0 0;
  color: var(--accent);
  font-size: 0.85rem;
}
.btn-suggested { border-color: var(--accent); color: var(--accent); }
.todo-items { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.todo-items li { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.12rem 0; }
.item-toggle {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}
span.item-done { color: var(--muted); text-decoration: line-through; }
.todo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.55rem 0 0;
  align-items: center;
}
.todo-note-link {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.08rem 0.55rem;
}
.todo-note-link:hover { color: var(--accent); border-color: var(--accent); }
.todo-note-completion { border-color: var(--accent); color: var(--accent); }

/* A newly arrived item flashes bright and settles. */
.flash-new {
  animation: flash-in 900ms ease-out;
  border-radius: 10px;
}
@keyframes flash-in {
  0% { background-color: var(--flash); transform: translateY(-6px); }
  55% { background-color: var(--flash); transform: none; }
  100% { background-color: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-new { animation: none; }
}

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

.search-form {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 2.25rem;
}
.search-form input[type="search"] {
  flex: 1;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.search-form input[type="search"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.search-clear {
  color: var(--muted);
  font-size: 0.88rem;
}
.search-note {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---- Outbox: entries waiting out a dead network ---- */

.outbox {
  margin-top: 1.1rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 14px;
}
.outbox-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.outbox .entry { padding: 0.6rem 0 0.2rem; opacity: 0.8; }
.outbox .entry + .entry { border-top: 1px solid var(--border); }

/* ---- Entries ---- */

.entries { margin-top: 1.1rem; }

.entry { padding: 1rem 0; }
.entry + .entry { border-top: 1px solid var(--border); }

.entry-meta {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.entry-body p { margin: 0 0 0.6em; }
.entry-body p:last-child { margin-bottom: 0; }

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

/* ---- The gate (sign-in and denial) ---- */

.gate {
  padding-top: 5rem;
  text-align: center;
}
.gate h1 { margin: 0 0 0.3rem; }
.gate-sub { margin: 0 0 1.75rem; color: var(--muted); }

/* Panes: both tabs stay in the DOM. The one not showing leaves the
   flow entirely; during a slide the incoming pane rides absolutely
   over the outgoing one and the container clips the overshoot. */
.panes { position: relative; }
.panes.sliding { overflow: hidden; }
.pane-in { position: absolute; left: 0; right: 0; }
.pane-error {
  margin: 0.8rem 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}
