/* ============================================================
   JOURNAL — the journals index
   The LEDGER look above, with a month of entries per card. A row keeps the journal's
   own signature — a large light day numeral beside the writing — and the summary card
   carries a streak strip: one cell per day of the month, or per month of the year,
   filled where something was written.
   ============================================================ */

/* A journal row is one day of writing, so it reads better in a narrower column than the
   rules and values lists — the mirror of what .is-wide does for the things tree. */
.ledger-page.jd-page { max-width: 720px; }

/* The span picker is a <details>, so paging between months needs no JavaScript. */
.jd-picker > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  list-style: none;
}
.jd-picker > summary::-webkit-details-marker { display: none; }
.jd-picker[open] > .ledger-month-menu { display: block; }
.ledger-nav-btn.is-disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* A day written on fills a soft green, deeper the more was written; in the year view a
   month is as deep as the share of its days that were written on (--share, 0-1, from
   JournalsHelper#journal_strip_groups), so a month with one entry no longer looks like
   a month with thirty. */
.ledger-strip.jd-streak .ledger-day.is-rated {
  --fill: rgba(34, 197, 94, calc(0.18 + var(--share, 1) * 0.6));
  color: var(--text-1);
}
.ledger-strip.jd-streak .ledger-day { cursor: default; }

.jd-strip-note {
  margin: 10px 0 0;
  color: var(--text-3);
  font-size: var(--fs-11);
}

/* Rows: day numeral · thumbnails · the writing and its meta. */
.jd-list { margin: 0; padding: 4px 0; list-style: none; }
.jd-entry {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
  transition: background-color var(--dur-fast) ease;
}
.jd-entry:first-child { border-top-color: transparent; }
@media (hover: hover) { .jd-entry:hover { background-color: rgba(255, 255, 255, 0.025); } }
.jd-entry:focus-within { background-color: rgba(255, 255, 255, 0.04); }
/* Filed under an area: the area's colour as a thin line at the left edge (a favourite's
   gold, below, takes the edge instead). */
.jd-entry.has-area { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--area) 80%, transparent); }
/* A favourite: a faint warm wash and a thin gold edge, the way a favourite inspiration
   wears its gold. Keyed off the set bookmark inside the row, so it follows the bookmark
   the moment it's toggled — the toggle redraws only the button. */
.jd-entry:has(.jd-fav-btn.is-on) {
  background-color: rgba(251, 191, 36, 0.045);
  box-shadow: inset 2px 0 0 rgba(251, 191, 36, 0.7);
}
.jd-entry:has(.jd-fav-btn.is-on):hover { background-color: rgba(251, 191, 36, 0.07); }

/* Stretched over the whole row, so the row is clickable without an onclick handler and
   still reachable by keyboard. Controls inside the row are lifted back above it. */
.jd-entry-link { display: block; color: inherit; text-decoration: none; }
.jd-entry-link::after { content: ''; position: absolute; inset: 0; border-radius: 8px; }
.jd-entry-link:focus-visible::after { outline: 2px solid var(--text-2); outline-offset: -2px; }
.jd-entry .jd-fav-wrap,
.jd-entry .jd-task-ref,
.jd-entry .jd-memo-player { position: relative; z-index: 1; }

.jd-date-block { flex-shrink: 0; width: 34px; padding-top: 1px; text-align: center; }
/* A second entry on the same day sits under the first: its date column is kept for the
   alignment but left empty, and the rule between them is lighter. */
.jd-entry.is-same-day .jd-date-block > :not(.jd-where) { visibility: hidden; }
.jd-entry.is-same-day { border-top-color: transparent; padding-top: 0; }
.jd-day-num {
  display: block;
  color: var(--text-1);
  font-size: 26px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.jd-day-label {
  display: block;
  margin-top: 3px;
  color: var(--text-3);
  font-size: var(--fs-9);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.jd-thumbs { display: flex; flex-shrink: 0; gap: 3px; align-self: center; }
.jd-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.jd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jd-thumb-more { color: var(--text-3); font-size: var(--fs-12); }

/* A picture-only entry: the photos take the width the writing would have had, kept at
   the row's own height and cropped top and bottom rather than made taller. Each photo
   takes an equal share, so the more there are the less any one of them is cropped. */
.jd-entry.is-photo-row { align-items: flex-start; }
.jd-entry.is-photo-row .jd-date-block { width: 58px; }
.jd-entry.is-photo-row .jd-where { margin-top: 4px; white-space: nowrap; }
.jd-entry.is-photo-row .jd-thumbs { flex: 1; min-width: 0; gap: 4px; align-self: flex-start; }
/* Taller than a list thumbnail: at full width there is room for it, and the extra
   height is crop the pictures do not lose. */
.jd-entry.is-photo-row .jd-thumb { flex: 1; width: auto; min-width: 0; height: 100px; }
.jd-entry.is-photo-row .jd-thumb-more { flex: 0 0 34px; }
.jd-entry-link-bare { position: absolute; inset: 0; }

.jd-content { flex: 1; min-width: 0; }
.jd-where { margin-bottom: 2px; color: var(--text-3); font-size: var(--fs-11); }

/* The writing itself, in the serif — read like a journal, not scanned like a list. */
.jd-preview {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-bottom: 4px;
  color: var(--text-2);
  font-family: Newsreader, Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;
  text-wrap: pretty;
}
.jd-preview.jd-preview-full { display: block; -webkit-line-clamp: unset; white-space: pre-wrap; }
.jd-preview.is-empty { color: var(--text-3); font-style: italic; }
.jd-entry:hover .jd-preview { color: var(--text-1); }

.jd-task-ref { margin-bottom: 3px; font-size: var(--fs-11); font-style: italic; }
.jd-task-ref a { color: var(--text-3); text-decoration: none; }
.jd-task-ref a:hover { color: var(--text-1); text-decoration: underline; text-underline-offset: 3px; }

.jd-memo-name { margin-bottom: 3px; color: var(--text-3); font-size: var(--fs-11); }
.jd-memo-working { color: var(--text-2); }
.jd-memo-failed { color: var(--danger-bright); }
.jd-memo-player { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.jd-memo-player audio { flex: 1; min-width: 0; height: 24px; accent-color: var(--accent); }

.jd-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.jd-fav-wrap, .jd-fav-form { display: inline-flex; margin: 0; }
/* The bookmark's slot at the row's end, level with the first line of text. An unset
   bookmark appears only with its row's hover, so a month of entries isn't a column of
   outlines; a set one stays gold. A phone has no hover, so there it stays faintly in
   sight. */
.jd-fav-col { flex-shrink: 0; width: 20px; display: flex; justify-content: center; padding-top: 4px; }
.jd-fav-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--text-3);
  font-size: var(--fs-13);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: color var(--dur-fast) ease, opacity var(--dur-fast) ease;
}
.jd-entry:hover .jd-fav-btn, .jd-fav-btn:focus-visible { opacity: 1; }
.jd-fav-btn:hover, .jd-fav-btn.is-on { color: var(--gold-bright); opacity: 1; }
@media (hover: none) {
  .jd-fav-btn { opacity: 0.4; }
}

/* An entry begun from a question: the question heads it, quietly, over the answer. */
.jd-question {
  display: block;
  margin-bottom: 2px;
  color: var(--text-3);
  font-family: Newsreader, Georgia, serif;
  font-size: 13px;
  font-style: italic;
  line-height: 1.4;
}

/* The day's value score, under the weekday: the home dial's number, in the values violet. */
/* Quiet: grey figures and only a dot in the dial's colour. A filled red chip on every
   day under 60% made the journal read as a list of failures beside what was written —
   the reason the calendar dropped its red rings too. The full reading is the hover. */
.jd-day-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.jd-day-score::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--score-color, #a78bfa);
}

/* Today, not yet written: a box to start in on the page itself. */
.jd-today {
  margin-bottom: 14px;
  padding: 12px 14px 10px;
  border: 1px solid var(--border-panel);
  border-radius: var(--radius-lg);
  background-color: var(--surface-card);
  background-image: var(--sheen);
  box-shadow: inset 0 1px 0 var(--inset-light), 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: border-color var(--dur-fast);
}
.jd-today:focus-within { border-color: rgba(34, 197, 94, 0.45); }
.jd-today-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.jd-today-label { color: var(--text-3); font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.jd-today-more { color: var(--text-3); font-size: var(--fs-11); text-decoration: none; }
.jd-today-more:hover { color: var(--text-1); }
.jd-today-input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-1);
  font-family: Newsreader, Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  box-sizing: border-box;
}
.jd-today-input::placeholder { color: var(--text-3); font-style: italic; }
.jd-today-foot { display: flex; justify-content: flex-end; }
/* The arrow is .task-form-submit's (the journal modal's); here it sits back until there's
   something to save. */
.jd-today-save { opacity: 0.45; transition: opacity var(--dur-fast); }
.jd-today:focus-within .jd-today-save, .jd-today-save:hover { opacity: 0.8; }

/* On this day: what was written on today's date a month or a year ago. */
.jd-memories { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 14px; }
.jd-memory {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(167, 139, 250, 0.08), transparent 60%), var(--surface-card);
  text-decoration: none;
  transition: border-color var(--dur-fast);
}
.jd-memory:hover { border-color: rgba(167, 139, 250, 0.45); }
.jd-memory-when { display: inline-flex; align-items: center; gap: 6px; color: #c4b5fd; font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.jd-memory-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--text-2);
  font-family: Newsreader, Georgia, serif;
  font-size: 14px;
  line-height: 1.45;
}
.jd-memory:hover .jd-memory-text { color: var(--text-1); }
.jd-tag { color: var(--text-3); font-size: var(--fs-11); }

/* A hashtag typed into an entry, coloured where the entry text is shown — the same
   blue the library gives its hashtags (.lib-hashtag). */
.entry-hashtag { color: #93c5fd; }

/* Typing an entry: the coloured copy of the value is painted on .eh-backdrop directly
   behind the textarea, which keeps its own text transparent and only its caret visible.
   The two share their metrics — the controller copies them off the textarea — so the
   words wrap to the same places. */
.eh-wrap { position: relative; }
.eh-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 0 solid transparent;
  color: var(--text-1);
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
}
.eh-input {
  position: relative;
  background-color: transparent !important;
  color: transparent !important;
  caret-color: var(--text-1);
}
.eh-input::placeholder { color: var(--text-3); }

/* The tag menu, opened by "#". It sits under the textarea rather than at the caret, so
   it never covers the words being typed. */
.eh-menu {
  position: absolute;
  z-index: 60;
  left: 0;
  min-width: 180px;
  max-height: 210px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-2, #1c1c1e);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}
.eh-menu-item {
  display: block;
  width: 100%;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: none;
  color: #93c5fd;
  font-size: var(--fs-13);
  text-align: left;
  cursor: pointer;
}
.eh-menu-item[data-active="true"] { background: var(--surface-row); color: #bfdbfe; }

/* The marker syntax, under an entry field once it has been focused. */
.eh-hint {
  margin-top: 4px;
  color: var(--text-3);
  font-size: var(--fs-11);
  line-height: 1.4;
}
.eh-hint[hidden] { display: none; }

/* The Photos pill: the thumbnails are the content, so they get the card to themselves. */
.jd-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
  padding: 12px 14px 14px;
}
.jd-gallery-cell {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: box-shadow var(--dur-fast) ease, transform var(--dur-fast) ease;
}
.jd-gallery-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jd-gallery-cell:hover { transform: scale(1.02); box-shadow: 0 0 0 2px var(--border-strong); }

@media (max-width: 720px) {
  .jd-entry { gap: 12px; padding: 14px 12px; }
  .jd-thumbs { align-self: flex-start; }
  .jd-thumb { width: 44px; height: 44px; }
  .jd-entry.is-photo-row .jd-thumbs { align-self: flex-start; }
  .jd-entry.is-photo-row .jd-thumb { width: auto; height: 84px; }
  .jd-gallery { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}

/* ---- Journal: write in the serif it's read in; the form's footer and the year ---- */
/* The shared title-field rules (.task-form-input-title, 14px !important, Inter) came later
   and won over .jd-form-entry's serif; this says it with the weight to win. The hashtag
   backdrop copies the field's font, so the two still line up. Line height stays at
   .jd-form-entry's 1.35 (01-base.css): the caret is a line tall, and more leading
   makes it overshoot the serif's letters, worst in Safari. */
textarea.jd-form-entry.task-form-input-title {
  font-family: Newsreader, Georgia, 'Times New Roman', serif !important;
  font-size: 15px !important;
  line-height: 1.35;
}
/* Favorite names itself beside its bookmark. */
.icon-card[data-type="favorite"] { width: auto; gap: 7px; padding-inline: 12px; }
.jd-fav-label { color: var(--text-3); font-size: var(--fs-12); }
.icon-card[data-type="favorite"][aria-pressed="true"] .jd-fav-label { color: var(--gold-bright, #fbbf24); }
/* Batch import keeps its drop target (dragging files over the form opens it) but not its
   line; the Journal page's Import button is the way there on purpose. */
.jd-bulk .jd-disclosure:not([open]) { display: none; }
/* The months still to come, set back from the ones gone by, so the year reads in progress. */
.jd-streak .ledger-day.is-future { opacity: 0.4; background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }

/* ---- Journal: the header, the year at a glance ---- */
/* Title and its ‹ span › together, New entry and Import on the right (journals/index). */
.jd-head .ledger-head-left { flex-wrap: wrap; row-gap: 8px; }
.jd-head .ledger-month { margin-right: 0 !important; }
.jd-head-actions { display: flex; align-items: center; gap: 8px; }
@media (min-width: 820px) { .jd-head-actions { margin-right: 46px; } }
@media (max-width: 640px) { .jd-head .ledger-month { order: 0; width: auto; } }
/* Writing is what this page is for: New entry is the one solid button. */
.ledger-new.jd-new-entry { border-color: transparent; background: var(--accent); color: #04130a; font-weight: 600; opacity: 1; }
.ledger-new.jd-new-entry:hover { background: var(--accent-bright, #4ade80); color: #04130a; }
.ledger-new.jd-import { padding-left: 9px; padding-right: 9px; }
/* A month nothing was written in: an outline, not a filled cell like the ones that were,
   so the strip shows the year's shape at a glance. Months to come stay fainter still. */
.ledger-strip.jd-streak .ledger-day:not(.is-rated):not(.is-future) {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  color: var(--text-3);
}

/* ---- Journal: the entry form, with the writing first ---- */
/* Room to write: the box is what the form is for. */
.jd-form-entry { min-height: 11rem; }
/* Photo, Record and Audio as a row of small buttons rather than three large tiles. */
.jd-attach-row .icon-card { flex-direction: row; width: auto; height: 32px; padding: 0 11px; gap: 7px; border-radius: 999px; }
.jd-attach-row .icon-card i { font-size: var(--fs-12); }
.jd-attach-row .icon-card span { font-size: var(--fs-12); }
.jd-place-field[hidden] { display: none; }
/* Favorite: a bookmark by the submit, not a labelled tile. */
.jd-contents .icon-card[data-type="favorite"] { width: 34px; height: 34px; padding: 0; border-radius: 50%; }
.jd-contents .icon-card[data-type="favorite"] .jd-fav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- A row's photos under its words, so every entry's text starts at one edge ---- */
.jd-content > .jd-thumbs { align-self: auto; margin: 8px 0 4px; position: relative; z-index: 1; pointer-events: none; }
.jd-content > .jd-thumbs .jd-thumb { width: 64px; height: 64px; }

/* ---- Tags inside the writing in grey, brightening on hover, so the words lead ---- */
.jd-preview .entry-hashtag, .js-entry .entry-hashtag { color: var(--text-3); transition: color var(--dur-fast); }
.jd-entry:hover .jd-preview .entry-hashtag, .js-entry .entry-hashtag:hover { color: var(--text-2); }

/* ---- The area an entry is filed under, named under its weekday ---- */
.jd-day-area {
  display: block; overflow: hidden; margin-top: 4px;
  color: color-mix(in srgb, var(--area, var(--text-3)) 75%, #fff); opacity: 0.8;
  font-size: 8px; font-weight: 600; letter-spacing: 0.06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap;
}
.jd-entry.has-area .jd-date-block { width: 40px; }

/* ---- The year strip: months before the account began set back like those to come;
   a month with nothing written fainter still than an outline ---- */
.jd-streak .ledger-day.is-before { opacity: 0.35; background: transparent; box-shadow: none; }
.ledger-strip.jd-streak .ledger-day:not(.is-rated):not(.is-future):not(.is-before) { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); color: var(--text-3); opacity: 0.75; }

/* ---- The header: the year and its arrows as one control; New entry quiet ---- */
.jd-head .ledger-month { gap: 2px; }
.jd-head .ledger-month-label { min-width: 0; padding: 0 8px; }
.jd-head .ledger-nav-btn { border-color: transparent; }
.jd-head .ledger-nav-btn:hover { border-color: var(--border); }
.ledger-new.jd-new-entry { border-color: var(--border-strong); background: transparent; color: var(--text-1); font-weight: 500; }
.ledger-new.jd-new-entry:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.ledger-new.jd-new-entry i { color: var(--accent-bright); }
.ledger-new.jd-import { gap: 6px; padding-left: 11px; padding-right: 11px; }
@media (max-width: 640px) {
  /* Title and the year on one line, the buttons beside them, rather than spread over two
     rows with a gap. */
  .jd-head { flex-wrap: nowrap; align-items: center; gap: 8px; }
  .jd-head .ledger-head-left { flex-wrap: nowrap; gap: 6px; min-width: 0; }
  .jd-head .ledger-month { width: auto; order: 0; justify-content: flex-start; }
  .jd-head-actions { margin-left: auto; gap: 6px; }
  .ledger-new.jd-new-entry, .ledger-new.jd-import { padding: 0 9px; }
  .ledger-new.jd-new-entry { font-size: 0; gap: 0; }
  .ledger-new.jd-new-entry i { font-size: var(--fs-13); }
  .ledger-new.jd-import { font-size: 0; gap: 0; }
  .ledger-new.jd-import i { font-size: var(--fs-13); }
}

/* ---- An entry's photos under its words, in a row of smaller frames ---- */
.js-show .js-photos-section .js-gallery,
.js-show .js-photos-section .js-gallery.count-2,
.js-show .js-photos-section .js-gallery.count-many { grid-template-columns: repeat(auto-fill, minmax(120px, 180px)); }
.js-show .js-photos-section .js-gallery.count-1 { grid-template-columns: minmax(0, 360px); }
.js-photos-section .js-photo { aspect-ratio: 1 / 1 !important; }
.js-photos-section .js-image { max-height: 320px; width: auto; max-width: 100%; border-radius: var(--radius-md); }

/* ---- The form ---- */
/* Time and place not set yet: a solid quiet chip with a +, not a dashed one that read as broken. */
.jd-when-chip.is-empty { border-style: solid; border-color: var(--border); }
.jd-when-chip.is-empty::before { content: '+'; margin-right: -2px; color: var(--text-3); font-weight: 600; }
.jd-when-chip.is-empty i { display: none; }
/* Favourite says so beside its bookmark. */
.jd-contents .icon-card[data-type="favorite"] { flex-direction: row; width: auto; height: 34px; padding: 0 12px 0 10px; gap: 7px; border-radius: 999px; }
.jd-contents .icon-card[data-type="favorite"] .jd-fav-label { font-size: var(--fs-12); }
.jd-contents .icon-card[data-type="favorite"] .jd-fav-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
/* Tags: an entry's own, the rest behind "Add a tag". */
.jd-tags.is-own-only > label.is-other { display: none; }
.jd-tag-more {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border: 1px dashed var(--border-strong); border-radius: 999px; background: none;
  color: var(--text-3); font: inherit; font-size: var(--fs-12); cursor: pointer;
}
.jd-tag-more:hover { color: var(--text-1); border-color: var(--text-3); }
.jd-tag-more i { font-size: var(--fs-10); }

/* Import, for a free account: Premium's gold lock beside it (journals/index). */
.jd-import-lock { margin-left: 6px; color: var(--gold-bright); font-size: 0.75em; }

/* Months before the account began: faint text, no box (a later outline rule had drawn
   them as empty cells, as if they'd been skipped). */
.ledger-strip.jd-streak .ledger-day.is-before { box-shadow: none !important; background: transparent !important; }
