/* Daily Life Doc, revision 3: the Library. The list with its filter row (js/library/library.js), an
   entry's page (library-entry.js), the finding's sheet and the floating Mark control (finding.js) and the composer
   (composer.js). Colours are tokens only: the place's colour through --pc-bg / --pc / --pc-d, the findings in
   green, red and amber. Nothing here changes on hover and no state moves a neighbour. */

/* ---------- The filter row: held at the top while the list scrolls ---------- */
/* The scroll area has a top padding of the bars' height + 10px and holds things inside it: -10px puts the row right under the bars. */
.lib-bar { position: sticky; top: -10px; z-index: 5; margin: 0 calc(var(--gut) * -1) 4px; padding: 8px var(--gut); transition: background-color var(--m-step) ease, box-shadow var(--m-step) ease; }
.lib-bar .filters { margin: 0 calc(var(--gut) * -1); }
.lib-bar::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--top, 0px); background: inherit; -webkit-backdrop-filter: inherit; backdrop-filter: inherit; pointer-events: none; }
.lib-bar.stuck { background: color-mix(in srgb, color-mix(in srgb, var(--pc-bg) 60%, var(--bg)) 95%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: 0 1px 0 var(--line); }

/* ---------- The list: one card per entry ---------- */
.lib-list { display: flex; flex-direction: column; gap: 12px; }
.lib-e { display: block; padding: 15px 18px 11px; border-radius: 22px; background: var(--surface); cursor: pointer; box-shadow: 0 1px 0 var(--line); }
/* Room under the last clipped line for the lower of two underlines. */
.lib-text .fdx.clamp { padding-bottom: 5px; margin-bottom: -5px; }
.lib-foot { display: flex; align-items: center; gap: 8px; min-height: 26px; margin-top: 9px; font-size: var(--t-xs); font-weight: 500; color: var(--ink3); }
.lib-foot time { flex: none; }
.lib-from { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; background: var(--pc-bg); color: var(--pc-d); }
.lib-marks { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 10px; min-height: 18px; }
.lib-marks span { display: inline-flex; align-items: center; gap: 3px; }
.lib-marks i { width: 15px; height: 15px; }
.lib-marks b { font-weight: 600; }
.lib-none { animation: dd-fade 220ms ease both; }

/* ---------- An underline that draws in from left to right (DD.library.drawIn) ----------
   While it is drawn the real underline is hidden and a line of the same colour and place grows under the words. */
.fd.fd-draw { --fd-c: var(--ink3); text-decoration-color: transparent !important; transition: none; padding-bottom: 3px;
  background: linear-gradient(var(--fd-c), var(--fd-c)) no-repeat 0 100% / 0% 2px; }
.fd.fd-2.fd-draw { padding-bottom: 8px; }
.fd-draw[data-tag="helped"] { --fd-c: var(--good); }
.fd-draw[data-tag="nothelped"] { --fd-c: var(--bad); }
.fd-draw[data-tag="worse"] { --fd-c: var(--bad-d); }
.fd-draw[data-tag="totry"] { --fd-c: var(--try); }
.fd-draw.dim { --fd-c: var(--line); }

/* ---------- An entry's page ---------- */
.le-doc { display: flex; flex-direction: column; gap: 16px; padding: 18px 18px 20px; animation: dd-rise var(--m-add) var(--ease-out) both; }
.le-top { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-bottom: -6px; font-size: var(--t-sm); font-weight: 500; color: var(--ink2); }
.le-text .fdx { -webkit-user-select: text; user-select: text; }
.le-text ::selection { background: var(--pc-bg); }
/* While the first and the last word are asked for, the text is framed in the place's colour (a shadow: nothing moves). */
.le-text { border-radius: 6px; transition: background-color var(--m-step) ease, box-shadow var(--m-step) ease; }
.lm-on .le-text { background: color-mix(in srgb, var(--pc-bg) 45%, transparent); box-shadow: 0 0 0 8px color-mix(in srgb, var(--pc-bg) 45%, transparent); }
.lm-on .le-text .fdx { cursor: text; }
.le-links { display: flex; flex-direction: column; gap: 8px; }
.le-files.ph-strip { margin: 0; gap: 8px; }
.le-files .ph-t:not(.doc) { width: 76px; height: 76px; border-radius: 14px; }
.le-actions { margin-top: 14px; flex-wrap: nowrap; }
.le-actions .btn { height: 52px; padding: 0 8px; gap: 7px; font-size: var(--t-m); }
.le-actions .btn svg { width: 19px; height: 19px; }

/* ---------- The floating Mark control: "Mark" and the four tags, under the selected words ---------- */
.lm { position: absolute; z-index: 46; display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 18px; background: var(--ink); color: var(--on-ink);
  box-shadow: 0 14px 30px -14px var(--shadow); animation: lm-in 200ms var(--ease-out) both; }
@keyframes lm-in { from { opacity: 0; transform: translateY(4px) scale(.96); } }
.lm > b { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; padding: 0 8px 0 6px; font-size: var(--t-xs); font-weight: 600; }
.lm > b svg { width: 18px; height: 18px; }
.lm-tags { display: grid; grid-template-columns: auto auto; gap: 6px; }
.lm button { height: 38px; padding: 0 12px 0 10px; border-radius: 11px; display: inline-flex; align-items: center; gap: 8px; background: color-mix(in srgb, var(--on-ink) 15%, transparent);
  font-size: var(--t-sm); font-weight: 500; white-space: nowrap; transition: transform var(--m-press) var(--ease-out); }
.lm button:active { transform: scale(0.95); }
.lm-tags i, .lf-tag i, .lc-legend i { flex: none; width: 16px; height: 0; border-top: 3px solid var(--good); border-radius: 2px; }
.lm-tags [data-tag="nothelped"] i, .lf-tag[data-tag="nothelped"] i { border-color: var(--bad); }
.lm-tags [data-tag="worse"] i { border-top-style: dashed; border-color: var(--bad); border-radius: 0; }
.lf-tag[data-tag="worse"] i { border-top-style: dashed; border-color: var(--bad-d); border-radius: 0; }
.lm-tags [data-tag="totry"] i, .lf-tag[data-tag="totry"] i { border-color: var(--try); }
.lm.ask { left: 16px; right: 16px; bottom: 24px; justify-content: space-between; padding-left: 16px; }
.lm.ask span { font-size: var(--t-s); font-weight: 500; }

/* ---------- A finding's sheet: the words, the four tags, Remove and New experiment ---------- */
.lf-quotes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lf-q { display: block; width: 100%; padding: 11px 14px 13px; border-radius: 16px; background: var(--soft); text-align: left; font-size: var(--t-m); line-height: 28px; cursor: default;
  transition: box-shadow var(--m-step) ease, opacity var(--m-step) ease; }
.lf-q .fd { cursor: inherit; }
.lf-q:not([tabindex]) { cursor: pointer; }
.lf-q:not([tabindex])[aria-pressed="false"] { opacity: .6; }
.lf-q:not([tabindex])[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--ink); }
.lf-tags { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lf-tag { height: 50px; padding: 0 12px; border-radius: 14px; display: flex; align-items: center; gap: 9px; background: var(--soft); text-align: left; font-size: var(--t-s); font-weight: 500;
  transition: background-color var(--m-step) ease, color var(--m-step) ease, transform var(--m-press) var(--ease-out); }
.lf-tag:active { transform: scale(0.97); }
.lf-tag span { flex: 1; min-width: 0; }
.lf-tag b { flex: none; width: 18px; height: 18px; opacity: 0; }
.lf-tag[aria-pressed="true"] { font-weight: 600; }
.lf-tag[aria-pressed="true"] b { opacity: 1; }
.lf-tag[aria-pressed="true"][data-tag="helped"] { background: var(--good-bg); color: var(--good-d); }
.lf-tag[aria-pressed="true"][data-tag="nothelped"], .lf-tag[aria-pressed="true"][data-tag="worse"] { background: var(--bad-bg); color: var(--bad-d); }
.lf-tag[aria-pressed="true"][data-tag="totry"] { background: var(--try-bg); color: var(--try-d); }
.lf-acts { display: flex; gap: 10px; margin-top: 16px; }
.lf-acts .btn { flex: 1; height: 52px; padding: 0 12px; font-size: var(--t-m); white-space: nowrap; }
.lf-acts .btn svg { width: 19px; height: 19px; }

/* ---------- The composer: one tinted box with live underlines, the legend, Photo, File, Save ---------- */
.lc { display: flex; flex-direction: column; }
textarea.lc-box { min-height: 136px; max-height: 292px; padding: 12px 14px; overflow-y: auto; font-size: var(--t-m); line-height: 28px; scrollbar-width: none; }
.lc-box::-webkit-scrollbar { display: none; }
.lc.reading .fd-live { animation: dd-wait 1100ms ease-in-out infinite; }
.lc-legend { display: flex; align-items: center; gap: 10px; min-height: 20px; margin-top: 10px; padding: 0 2px; font-size: var(--t-2xs); font-weight: 500; color: var(--ink3); white-space: nowrap; }
.lc-legend span { display: inline-flex; align-items: center; gap: 5px; transition: color var(--m-step) ease; }
.lc-legend i { width: 13px; border-color: var(--line); transition: border-color var(--m-step) ease; }
.lc-legend .on { color: var(--ink); }
.lc-legend .on[data-tag="helped"] i { border-color: var(--good); }
.lc-legend .on[data-tag="nothelped"] i { border-color: var(--bad); }
.lc-legend .on[data-tag="worse"] i { border-color: var(--bad-d); }
.lc-legend [data-tag="worse"] i { border-top-style: dashed; border-radius: 0; }
.lc-legend .on[data-tag="totry"] i { border-color: var(--try); }
.lc-legend .dots { margin-left: auto; color: var(--pc); }
.lc-legend .dots i { width: 5px; height: 5px; border: 0; }
.lc-files.ph-strip { margin: 10px 0 0; }
.lc-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.lc-foot .btn { flex: none; padding: 0 13px; gap: 7px; }
.lc-gap { flex: 1; }
.lc-save { min-width: 78px; }
/* In an entry's Edit the row also holds Cancel: Photo and File keep their pictures and drop their words. */
.le-composer .lc-foot [data-photo], .le-composer .lc-foot [data-file] { width: 42px; padding: 0; font-size: 0; gap: 0; }

/* ---------- The link card (round 5; js/library/link-card.js): only in the Library ----------
   The whole card is one link that opens the page in a new tab; no buttons. Full card under an entry's text:
   an icon for the type, the title, "source · Type", then a short summary whose values carry the value underline
   (.lv from css/lines.css, read-only here). One line (.lk-mini) in the list and under the composer's box. */
.lk { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; border-radius: 18px; background: var(--bg); color: var(--ink); text-decoration: none; }
.lk-top { display: flex; align-items: flex-start; gap: 12px; }
.lk-top .tile { flex: none; margin-top: 1px; }
.lk-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lk-t b { font-size: var(--t-m); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.lk-t small { font-size: var(--t-xs); font-weight: 500; line-height: 1.4; color: var(--pc-d); overflow-wrap: anywhere; }
/* 26px lines leave room for the underline of a value; four lines at most on a narrow phone. */
.lk-sum { font-size: var(--t-s); line-height: 26px; color: var(--ink2); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; padding-bottom: 4px; margin-bottom: -4px; }
.lk-sum .lv { color: var(--ink); font-weight: 500; cursor: inherit; }
.lk-sum .lv:active { background: none; }
.lk-in { animation: dd-fade 260ms ease both; }
/* Loading: the address stays readable, grey bars stand where the words will be, and the card breathes softly. */
.lk-wait { animation: dd-wait 1100ms ease-in-out infinite; }
.lk-wait b { font-weight: 500; color: var(--ink3); }
.lk-wait .tile { background: var(--soft); color: var(--ink3); }
.lk-bar { display: block; height: 10px; border-radius: 5px; background: var(--soft); }
.lk-t .lk-bar { width: 96px; margin-top: 4px; }
.lk-bar.short { width: 62%; }

.lk-mini { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px 0 10px; border-radius: 12px; background: var(--bg); color: var(--ink); text-decoration: none; font-size: var(--t-sm); }
.lk-mini i { flex: none; width: 16px; height: 16px; color: var(--pc-d); }
.lk-mini b { flex: 1 1 auto; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lk-mini small { flex: none; max-width: 56%; padding-left: 4px; font-size: var(--t-sm); color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lk-mini.lk-wait i, .lk-mini.lk-wait b { color: var(--ink3); }
.lk-rest { align-self: flex-start; padding: 0 4px; font-size: var(--t-xs); font-weight: 500; color: var(--ink3); }
.lib-links, .lc-links { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .lk-wait, .lk-in { animation: none; } }

/* ---------- Round 2: a pasted chat answer or web page as a formatted, read-only card (js/library/card.js) ----------
   The card is the paste; the patient's own note stands above it as plain words. Its words carry the findings'
   underlines (.fd from css/lines.css), so its lines are 26px high like every text with underlines. */
.le-note { font-size: var(--t-m); line-height: 28px; white-space: pre-wrap; overflow-wrap: anywhere; }
.le-card { padding: 16px 16px 18px; border-radius: 18px; background: var(--bg); }
.le-text .lx { -webkit-user-select: text; user-select: text; }
.lm-on .le-card { background: color-mix(in srgb, var(--pc-bg) 45%, var(--bg)); }
.lx { font-size: var(--t-s); line-height: 26px; color: var(--ink); overflow-wrap: anywhere; }
.lx-t { white-space: pre-line; }
.lx-gap { display: none; }
.lx > * + *, .lx blockquote > * + *, .lx li > * + * { margin-top: 12px; }
.lx h1, .lx h2 { font-size: var(--t-l); font-weight: 600; line-height: 1.35; letter-spacing: -0.005em; }
.lx h3, .lx h4, .lx h5, .lx h6 { font-size: var(--t-m); font-weight: 600; line-height: 1.4; }
.lx > .lx-h:not(:first-child) { margin-top: 22px; }
.lx b { font-weight: 600; }
.lx a { color: var(--focus); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.lx blockquote { margin: 0; padding-left: 14px; box-shadow: inset 2px 0 0 var(--ink3); color: var(--ink2); }
.lx ul, .lx ol { padding-left: 22px; }
.lx ul { list-style: disc; }
.lx ol { list-style: decimal; }
.lx li + li { margin-top: 4px; }
.lx li::marker { color: var(--ink3); }
.lx hr { height: 1px; border: 0; background: var(--line); }
.lx code { padding: 1px 5px; border-radius: 6px; background: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.lx-code { padding: 10px 12px; border-radius: 12px; background: var(--soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--t-xs); line-height: 20px; white-space: pre; overflow-x: auto; }
/* A table with short cells: an ordinary table that scrolls sideways inside the card when it is wider. */
.lx-scroll { overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
.lx-scroll::-webkit-scrollbar { display: none; }
.lx table { border-collapse: collapse; }
.lx-scroll table { min-width: 100%; }
.lx-scroll th, .lx-scroll td { padding: 5px 14px 5px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.lx-scroll th { font-size: var(--t-xs); font-weight: 600; color: var(--ink2); white-space: nowrap; }
.lx-scroll tr:last-child td { border-bottom: 0; }
/* A table with long cells: one block per row. The first cell is the row's title; every other cell stands under
   the name of its column, so nothing is wider than the card at 390 px. */
.lx-rows table, .lx-rows tbody, .lx-rows tr, .lx-rows td { display: block; }
.lx-rows thead { display: none; }
.lx-rows tr { padding: 14px 0; border-top: 1px solid var(--line); }
.lx-rows tr:last-child { padding-bottom: 0; }
.lx-rows td:first-child { font-size: var(--t-m); font-weight: 600; line-height: 1.4; }
.lx-rows td[data-label]::before { content: attr(data-label); display: block; margin-top: 10px; font-size: var(--t-2xs); font-weight: 600; line-height: 18px; color: var(--ink3); }

/* ---------- Round 5: the To try list at the end of an entry (js/library/totry.js) and the sheet of its one button,
   Add to experiment (js/library/totry-add.js). Text with a small round tick, no frames. ---------- */
.lt { display: flex; flex-direction: column; margin-top: 6px; }
.lt-h { display: flex; align-items: center; gap: 8px; min-height: 22px; font-size: var(--t-sm); font-weight: 600; color: var(--ink2); }
.lt-h i { flex: none; width: 16px; height: 0; border-top: 3px solid var(--try); border-radius: 2px; }
.lt-row, .lt-line { display: flex; align-items: flex-start; gap: 0 12px; width: 100%; text-align: left; }
.lt-row { padding: 8px 0; }
.lt-tick { flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--ink3); color: transparent;
  transition: background-color var(--m-press) ease, box-shadow var(--m-press) ease; }
.lt-tick svg { width: 13px; height: 13px; stroke-width: 3; }
[aria-pressed="true"] > .lt-tick { background: var(--ink); box-shadow: none; color: var(--on-ink); }
.lt-row:active .lt-tick, .lt-tickb:active .lt-tick { transform: scale(0.9); }
.lt-words { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; }
.lt-name { font-size: var(--t-m); font-weight: 500; line-height: 1.45; overflow-wrap: anywhere; transition: color var(--m-press) ease; }
.lt-meta { font-size: var(--t-sm); line-height: 1.45; color: var(--ink3); overflow-wrap: anywhere; }
.lt-row[aria-pressed="false"] .lt-name, .lt-tickb[aria-pressed="false"] + .lt-words .lt-name, .lt-line.is-held .lt-name { color: var(--ink3); }
.lt > .lt-go { margin-top: 10px; }
.lt-go { width: 100%; height: 52px; font-size: var(--t-m); }
.lt-go svg { width: 19px; height: 19px; }
/* The sheet: the experiment, the word Tracking, the lines as they will be added. A line that is open shows its
   words in a tinted box with no border, the seven days and the kind of value. */
.lt-sheet .sh-opt .state, .lt-exp .state { flex: none; }
.lt-exp { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; text-align: left; font-size: var(--t-m); font-weight: 600; }
.lt-exp > span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lt-chev { flex: none; display: grid; width: 18px; height: 18px; color: var(--ink3); }
.lt-chev svg { width: 18px; height: 18px; }
.lt-part { margin: 12px 0 2px; font-size: var(--t-sm); font-weight: 600; color: var(--ink2); }
.lt-line { flex-wrap: wrap; padding: 2px 0; }
.lt-tickb { flex: none; display: flex; align-items: flex-start; width: 34px; min-height: 44px; padding-top: 9px; margin-right: -12px; }
.lt-tickb .lt-tick { margin-top: 0; }
.lt-line .lt-words { min-height: 44px; padding: 8px 0; justify-content: center; }
.lt-line.is-held .lt-words { padding-left: 34px; }
.lt-ed { flex-basis: 100%; display: flex; flex-direction: column; gap: 10px; padding: 2px 0 12px 34px; animation: dd-fade 180ms ease both; }
.lt-in { width: 100%; height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--soft); font: inherit; font-size: var(--t-m); color: var(--ink); outline: 0; }
.lt-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.lt-day { height: 38px; min-width: 0; border-radius: 10px; background: var(--soft); color: var(--ink3); font-size: var(--t-xs); font-weight: 500;
  transition: background-color var(--m-press) ease, color var(--m-press) ease, transform var(--m-press) ease; }
.lt-day[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.lt-day:active { transform: scale(0.94); }
.lt-kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lt-kinds .seg { flex: 1 1 200px; display: flex; }
.lt-kinds .seg-o { flex: 1; min-width: 0; padding: 0 6px; }
.lt-unit { flex: 1 1 84px; width: auto; }
/* Add stays at the sheet's foot while the lines scroll behind it (round 5 walk: with twelve lines at 340 x 800 the
   button was below the edge). The foot reaches into the sheet's own padding (18px sides, 30px bottom); a sticky box
   stops at the scroller's padding, hence bottom: -30px, so that no line shows under the button. */
.lt-foot { position: sticky; bottom: -30px; z-index: 2; margin: 6px -18px -30px; padding: 10px 18px 22px; background: var(--surface); box-shadow: 0 -10px 12px -6px var(--surface); }

/* ---------- Round 2: the card of a paste under the composer's box (js/library/composer-paste.js) ---------- */
.lc-card { position: relative; margin-top: 10px; }
.lc-cardbox { max-height: 236px; overflow-y: auto; padding: 14px 44px 16px 14px; border-radius: 16px; background: var(--bg); scrollbar-width: none; }
.lc-cardbox::-webkit-scrollbar { display: none; }
.lc-card-x { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; background: var(--surface); }
.lc-card-x svg { width: 16px; height: 16px; }
.lc.has-card textarea.lc-box { min-height: 56px; }
.lib-note { margin-bottom: 4px; font-size: var(--t-m); line-height: 28px; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* Round 3: an entry saved before the reader read it. The quiet word "Reading…" (`.qw`, css/today.css) sits beside
   the date on its card and above the words on its page. */
.lib-foot .qw { font-size: inherit; }
.le-wait { margin: 0 0 6px; }
