/* journal.css (bản 3.6): Nhật ký làm lại, bảng chọn ảnh, máy ảnh trong app, trình phát giọng nói. Nạp sau breath.css. */

/* ---------- N01: câu hỏi hôm nay ---------- */
.jr { gap: var(--space-lg); }
.jhero { position: relative; display: grid; gap: var(--space-xs); padding: var(--space-lg) var(--space-md) var(--space-md); border-radius: var(--radius-card); overflow: clip;
  background: radial-gradient(120% 90% at 100% 0%, oklch(93% 0.06 85) 0%, transparent 60%), linear-gradient(160deg, oklch(96% 0.035 150), oklch(93% 0.05 165));
  box-shadow: 0 1px 0 var(--color-rule), 0 10px 24px -18px oklch(30% 0.06 160 / 0.5); }
.jhero::after { content: ""; position: absolute; right: -28px; top: -28px; width: 110px; height: 110px; border-radius: 50%; background: oklch(90% 0.09 85 / 0.55); pointer-events: none; }
.jhero > * { position: relative; z-index: 1; }
.jhero__date { font-size: var(--text-sm); color: var(--color-muted); font-weight: var(--weight-strong); }
.jhero__kicker { display: inline-flex; align-items: center; gap: var(--space-3xs); justify-self: start; padding: 2px var(--space-xs); border-radius: var(--radius-pill); background: oklch(98% 0.02 85 / 0.8); font-size: var(--text-sm); font-weight: var(--weight-strong); color: var(--color-accent-ink); }
.jhero__kicker .icon { width: 16px; height: 16px; }
.jhero__q { font-family: var(--font-display); font-size: var(--text-xl); line-height: 1.25; text-wrap: balance; }
.jhero__ask { color: var(--color-ink-2); margin-top: var(--space-2xs); }
.jhero__moods { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-3xs); margin: var(--space-2xs) 0 var(--space-xs); }
.jhero__moods button { display: grid; justify-items: center; gap: 2px; min-height: var(--tap); padding: var(--space-2xs) 0; border: 0; border-radius: var(--radius-chip); background: oklch(99% 0.01 150 / 0.7); color: var(--color-ink-2); font-size: var(--text-xs, 0.75rem); font-weight: var(--weight-strong); cursor: pointer; transition: transform var(--dur-micro) var(--ease-out), background-color var(--dur-short) var(--ease-out); -webkit-tap-highlight-color: transparent; }
.jhero__moods button svg { width: 38px; height: 38px; transition: transform 320ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)); }
.jhero__moods button:active svg { transform: scale(1.18) rotate(-6deg); }
.jhero__moods button.is-today { background: var(--color-card); box-shadow: inset 0 0 0 2px var(--color-select); }
.jhero__moods span { max-width: 100%; overflow-wrap: anywhere; text-align: center; line-height: 1.15; }
@media (hover: hover) { .jhero__moods button:hover { background: var(--color-card); } .jhero__moods button:hover svg { transform: translateY(-2px); } }
:root[data-text="200"] .jhero__moods, :root[data-text="150"] .jhero__moods { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- N01: 7 ngày qua ---------- */
.jweek { display: grid; gap: var(--space-xs); }
.jweek h2 { font-size: var(--text-md); }
.jweek__row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-3xs); list-style: none; padding: var(--space-xs); border-radius: var(--radius-card); background: var(--color-card); box-shadow: 0 1px 0 var(--color-rule); }
.jweek__d { display: grid; justify-items: center; gap: 4px; width: 100%; padding: var(--space-2xs) 0; border: 0; border-radius: var(--radius-chip); background: none; color: var(--color-muted); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-strong); cursor: pointer; }
.jweek__d:disabled { cursor: default; }
.jweek__d.is-today { background: var(--color-paper-2); color: var(--color-ink); }
.jweek__f { display: grid; place-items: center; width: 32px; height: 32px; }
.jweek__f svg { width: 32px; height: 32px; }
.jweek__d.has .jweek__f svg { animation: jpop 420ms var(--ease-spring, ease-out) both; }
.jweek__dot { width: 10px; height: 10px; border-radius: 50%; border: 2px dashed var(--color-rule); }
.jweek__dot.is-on { border: 0; background: var(--color-field-3); }
.jweek__w { white-space: nowrap; }
@keyframes jpop { from { transform: scale(0.4); opacity: 0; } }

/* ---------- N01: ngày này năm/tháng trước ---------- */
.jmemo { display: grid; gap: var(--space-xs); }
.jmemo__h { display: flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-md); }
.jmemo__h .icon { width: 20px; height: 20px; color: var(--color-accent-deep); }
.jmemo .jcard { background: linear-gradient(var(--color-card), var(--color-card)) padding-box, linear-gradient(120deg, oklch(82% 0.12 70), oklch(80% 0.1 150)) border-box; border: 2px solid transparent; }

/* ---------- N01: dòng thời gian ---------- */
.jtimeline { display: grid; gap: var(--space-lg); }
.jgroup { display: grid; gap: var(--space-xs); scroll-margin-top: var(--space-xl); border-radius: var(--radius-card); }
.jgroup.is-flash { animation: jflash 1.1s var(--ease-out) both; }
@keyframes jflash { 0%, 30% { box-shadow: 0 0 0 6px oklch(85% 0.1 85 / 0.7); } 100% { box-shadow: 0 0 0 6px transparent; } }
.jday { display: flex; align-items: center; gap: var(--space-xs); font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-muted); }
.jday b { font-family: var(--font-display); font-size: var(--text-2xl); line-height: 1; color: var(--color-ink); min-width: 1.6ch; }
.jday span { display: grid; line-height: 1.2; }
.jday em { font-style: normal; color: var(--color-ink-2); font-weight: var(--weight-strong); }
.jgroup__list { display: grid; gap: var(--space-xs); padding-left: var(--space-sm); border-left: 2px dashed var(--color-rule); margin-left: 0.8ch; }
.jcard { position: relative; display: grid; width: 100%; padding: 0; border: 0; border-radius: var(--radius-card); background: var(--color-card); color: var(--color-ink); text-align: left; font: inherit; overflow: clip; cursor: pointer;
  box-shadow: 0 1px 0 var(--color-rule), 0 8px 20px -16px oklch(30% 0.06 160 / 0.45); transition: transform var(--dur-micro) var(--ease-out); }
.jcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--mood); z-index: 1; }
.jcard:active { transform: scale(0.985); }
.jcard__cover { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--color-paper-2); }
.jcard__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jcard__more { position: absolute; right: var(--space-xs); bottom: var(--space-xs); padding: 2px var(--space-xs); border-radius: var(--radius-pill); background: oklch(20% 0.03 165 / 0.72); color: oklch(98% 0.01 150); font-size: var(--text-sm); font-weight: var(--weight-strong); }
.jcard__body { display: grid; gap: var(--space-2xs); padding: var(--space-sm) var(--space-md) var(--space-sm) calc(var(--space-md) + 4px); }
.jcard__q { font-size: var(--text-sm); color: var(--color-muted); font-weight: var(--weight-strong); }
.jcard__text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; }
.jcard__meta { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xs); align-items: center; color: var(--color-muted); font-size: var(--text-sm); }
.jcard__meta .icon { width: 18px; height: 18px; }
.jcard__mood, .jcard__voice { display: inline-flex; align-items: center; gap: 3px; }
.jcard__time { font-variant-numeric: tabular-nums; font-weight: var(--weight-strong); }
.jempty { padding-block: var(--space-lg); }

/* Tìm kiếm */
.jsearch { display: flex; align-items: center; gap: var(--space-2xs); animation: jdrop 260ms var(--ease-out) both; }
.jsearch .field__input { flex: 1 1 auto; min-width: 0; }
.jsearch__x { flex: none; padding-inline: var(--space-sm); }
.jchips { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.jchips .chip { cursor: pointer; border: 0; font: inherit; font-size: var(--text-sm); }
.top .btn.is-on { background: var(--color-select); color: var(--color-select-ink); }
@keyframes jdrop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- N02: trang viết ---------- */
.jw { gap: var(--space-md); padding-bottom: calc(var(--space-3xl) + var(--tap-l, 56px)); }
.jw__date { margin-top: calc(-1 * var(--space-xs)); }
.jw__lbl { font-size: var(--text-md); margin-bottom: var(--space-2xs); }
.jpaper { position: relative; display: grid; gap: var(--space-2xs); padding: var(--space-sm) var(--space-md) var(--space-xs); border-radius: var(--radius-card); background: var(--color-card);
  box-shadow: inset 0 4px 0 var(--mood), 0 1px 0 var(--color-rule), 0 10px 26px -20px oklch(30% 0.06 160 / 0.5); transition: box-shadow var(--dur-short) var(--ease-out); }
.jpaper:focus-within { box-shadow: inset 0 4px 0 var(--mood), 0 0 0 3px var(--color-select), 0 10px 26px -20px oklch(30% 0.06 160 / 0.5); }
.jpaper__ta { width: 100%; min-height: 132px; padding: var(--space-2xs) 0; border: 0; background: repeating-linear-gradient(transparent 0 calc(1.6em - 1px), var(--color-paper-2) calc(1.6em - 1px) 1.6em); background-attachment: local; color: var(--color-ink); font: inherit; font-size: var(--text-md); line-height: 1.6; resize: none; overflow: hidden; outline: none; }
.jpaper__ta::placeholder { color: var(--color-muted); opacity: 0.85; }
.jpaper__foot { display: flex; justify-content: space-between; gap: var(--space-xs); flex-wrap: wrap; color: var(--color-muted); font-size: var(--text-sm); border-top: 1px solid var(--color-paper-2); padding-top: var(--space-2xs); }
.jprompt { display: flex; align-items: center; gap: var(--space-2xs); padding: var(--space-2xs) 0 var(--space-xs); border-bottom: 1px dashed var(--color-rule); }
.jprompt__ic { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: oklch(94% 0.06 85); color: var(--color-accent-deep); }
.jprompt__ic .icon { width: 18px; height: 18px; }
.jprompt__q { flex: 1 1 auto; min-width: 0; font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.3; animation: jdrop 300ms var(--ease-out) both; }
.jprompt .btn--icon { flex: none; color: var(--color-muted); }
.jprompt--add { justify-content: flex-start; width: 100%; min-height: var(--tap); border: 0; border-bottom: 1px dashed var(--color-rule); background: none; color: var(--color-muted); font: inherit; font-weight: var(--weight-strong); cursor: pointer; text-align: left; }
.jprompt--add .icon { width: 20px; height: 20px; color: var(--color-accent-deep); }
.jtools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.jtool { display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 92px; padding: var(--space-xs) var(--space-2xs); border: 2px dashed var(--color-rule); border-radius: var(--radius-card); background: var(--color-card); color: var(--color-ink); font: inherit; font-weight: var(--weight-strong); font-size: var(--text-sm); text-align: center; cursor: pointer; transition: transform var(--dur-micro) var(--ease-out), border-color var(--dur-short) var(--ease-out); -webkit-tap-highlight-color: transparent; }
.jtool small { color: var(--color-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.jtool__ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--color-paper-2); }
.jtool__ic .icon { width: 24px; height: 24px; }
#jcam .jtool__ic { background: oklch(92% 0.06 225); }
#jlib .jtool__ic { background: oklch(93% 0.07 85); }
#jrec .jtool__ic { background: oklch(92% 0.06 20); color: var(--color-error); }
.jtool:active { transform: scale(0.96); }
.jtool:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
@media (hover: hover) { .jtool:not(:disabled):hover { border-color: var(--color-edge); } }
.jw__thumbs li { animation: jpop 360ms var(--ease-out) both; }
.jw__thumbs img { box-shadow: 0 1px 0 var(--color-rule); }
.jw__save { position: sticky; bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px)); z-index: var(--z-raised); margin-top: var(--space-xs); padding-top: var(--space-xs); background: linear-gradient(transparent, var(--color-paper) 40%); }
.jw .moods button svg { transition: transform 320ms var(--ease-spring, ease-out); }
.jw .moods button[aria-pressed="true"] svg { transform: scale(1.12); }

/* ---------- N04: đọc trang ---------- */
.cdots { display: flex; justify-content: center; gap: 6px; margin-top: calc(-1 * var(--space-xs)); }
.cdots i { width: 7px; height: 7px; border-radius: 50%; background: var(--color-rule); transition: width var(--dur-short) var(--ease-out), background-color var(--dur-short); }
.cdots i.is-on { width: 18px; border-radius: 4px; background: var(--color-select); }
.jread { position: relative; display: grid; gap: var(--space-sm); padding: var(--space-md); border-radius: var(--radius-card); background: var(--color-card); box-shadow: inset 0 4px 0 var(--mood), 0 1px 0 var(--color-rule); }
.jread__face { position: absolute; top: calc(-1 * var(--space-sm)); right: var(--space-md); width: 44px; height: 44px; filter: drop-shadow(0 2px 3px oklch(30% 0.05 160 / 0.2)); }
.jread__face svg { width: 44px; height: 44px; }
.jread__q { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.3; color: var(--color-ink-2); padding-right: 48px; }
.jread__text { white-space: pre-wrap; font-size: var(--text-md); line-height: 1.6; }

/* ---------- Trình phát giọng nói ---------- */
.vps { display: grid; gap: var(--space-xs); list-style: none; }
.vp { display: flex; align-items: center; gap: var(--space-xs); min-height: var(--tap-l, 56px); padding: var(--space-2xs) var(--space-2xs) var(--space-2xs) var(--space-2xs); border-radius: var(--radius-pill); background: var(--color-card); box-shadow: 0 1px 0 var(--color-rule); }
.vp__btn { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--color-select); color: var(--color-select-ink); cursor: pointer; transition: transform var(--dur-micro) var(--ease-out); }
.vp__btn:active { transform: scale(0.92); }
.vp__btn .icon { width: 22px; height: 22px; }
.vp__wave { position: relative; flex: 1 1 auto; min-width: 0; height: 32px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.vp__wave i { flex: 1 1 0; min-width: 2px; border-radius: 2px; background: var(--color-rule); }
.vp__fill { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: oklch(70% 0.1 160 / 0.35); mix-blend-mode: multiply; pointer-events: none; }
.vp.is-playing .vp__wave i { background: var(--color-edge); animation: vpb 900ms ease-in-out infinite alternate; }
.vp.is-playing .vp__wave i:nth-child(3n) { animation-delay: -300ms; }
.vp.is-playing .vp__wave i:nth-child(3n+1) { animation-delay: -600ms; }
@keyframes vpb { to { transform: scaleY(0.6); } }
.vp__time { flex: none; min-width: 4.2ch; font-variant-numeric: tabular-nums; font-weight: var(--weight-strong); font-size: var(--text-sm); text-align: right; padding-right: var(--space-2xs); }
.vp__rm { flex: none; }
.vp--rec { width: 100%; }

/* ---------- Bảng chọn ảnh ---------- */
.pick { display: grid; gap: var(--space-xs); }
.pick__opt { display: flex; align-items: center; gap: var(--space-sm); width: 100%; min-height: 72px; padding: var(--space-sm); border: 0; border-radius: var(--radius-card); background: var(--color-paper); color: var(--color-ink); font: inherit; text-align: left; cursor: pointer; box-shadow: 0 1px 0 var(--color-rule); transition: transform var(--dur-micro) var(--ease-out); }
.pick__opt:active { transform: scale(0.98); }
.pick__art { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 16px; }
.pick__opt--cam .pick__art { background: oklch(90% 0.07 225); }
.pick__opt--lib .pick__art { background: oklch(92% 0.08 85); }
.pick__art .icon { width: 28px; height: 28px; }
.pick__txt { display: grid; gap: 2px; min-width: 0; }
.pick__txt b { font-size: var(--text-md); }
.pick__txt small { color: var(--color-muted); font-size: var(--text-sm); }

/* ---------- Máy ảnh trong app ---------- */
.cam { position: absolute; inset: 0; z-index: calc(var(--z-modal) + 50); display: grid; grid-template-rows: 1fr auto; background: oklch(14% 0.02 165); color: oklch(97% 0.01 150); opacity: 0; transform: translateY(4%); transition: opacity 260ms var(--ease-out), transform 360ms cubic-bezier(0.32, 0.72, 0, 1); }
.cam.is-in { opacity: 1; transform: none; }
.cam__stage { position: relative; overflow: hidden; margin: calc(env(safe-area-inset-top, 0px) + 64px) var(--space-sm) 0; border-radius: 28px; background: oklch(20% 0.02 165); }
.cam__video, .cam__shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam__video.is-mirror { transform: scaleX(-1); }
.cam.is-flip .cam__stage { animation: camflip 400ms var(--ease-out); }
@keyframes camflip { 50% { transform: rotateY(90deg) scale(0.96); filter: blur(6px); } }
.cam__shot { animation: camshot 380ms var(--ease-out) both; }
@keyframes camshot { from { transform: scale(1.04); } }
.cam__flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam__flash.is-on { animation: camflash 360ms ease-out; }
@keyframes camflash { 0% { opacity: 0.9; } 100% { opacity: 0; } }
.cam__frame { position: absolute; inset: 18px; pointer-events: none; opacity: 0.7; }
.cam__frame i { position: absolute; width: 28px; height: 28px; border: 3px solid oklch(97% 0.01 150 / 0.85); }
.cam__frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.cam__frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 14px; }
.cam__frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 14px; }
.cam__frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.cam.is-review .cam__frame, .cam.is-nocam .cam__frame { display: none; }
.cam__msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--space-md); padding: var(--space-xl); text-align: center; }
.cam__msg[hidden] { display: none; }
.cam__msg-t { max-width: 26ch; line-height: 1.5; }
.cam__top { position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + var(--space-xs)); display: flex; align-items: center; gap: var(--space-xs); padding: 0 var(--space-sm); }
.cam__hint { flex: 1 1 auto; text-align: center; font-weight: var(--weight-strong); font-size: var(--text-sm); }
.cam__sp { width: 48px; flex: none; }
.cam__round { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%; background: oklch(97% 0.01 150 / 0.14); color: inherit; cursor: pointer; }
.cam__round .icon { width: 24px; height: 24px; }
.cam__round:active { transform: scale(0.92); }
.cam__bar { padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px)); }
.cam__live { display: flex; align-items: center; justify-content: space-between; }
.cam__live[hidden], .cam__review[hidden] { display: none; }
.cam__shutter { position: relative; width: 78px; height: 78px; border-radius: 50%; border: 4px solid oklch(97% 0.01 150); background: none; padding: 5px; cursor: pointer; }
.cam__shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: oklch(97% 0.01 150); transition: transform 160ms var(--ease-out), background-color 160ms; }
.cam__shutter:active span { transform: scale(0.86); background: var(--color-accent); }
.cam__shutter:disabled { opacity: 0.4; cursor: not-allowed; }
.cam__review { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); animation: jdrop 260ms var(--ease-out) both; }
.cam__btn.btn--secondary { border-color: oklch(97% 0.01 150 / 0.6); color: oklch(97% 0.01 150); }
.cam :focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .jweek__d.has .jweek__f svg, .jw__thumbs li, .jprompt__q, .jsearch, .cam__shot, .cam__review, .jgroup.is-flash { animation: none; }
  .vp.is-playing .vp__wave i { animation: none; }
  .cam { transition: none; }
}
.jr ~ .fab, .fab { transition: transform 280ms var(--ease-out), opacity 200ms var(--ease-out); }
.fab.is-away { opacity: 0; transform: translateY(24px) scale(0.9); pointer-events: none; }
.jprompt__next { flex: none; min-height: 36px; padding: 0 var(--space-xs); font-size: var(--text-sm); color: var(--color-ink-2); background: var(--color-paper); }
.jread:has(.jread__face) > .jread__face + .jread__text, .jread:has(.jread__face) > .jread__face + .cluster { padding-right: 44px; }
.cam.is-nocam .cam__live [data-act="flip"], .cam.is-nocam .cam__shutter { visibility: hidden; }
