.journal-period-card {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  width: 100%;
}

#journal-flipbook {
  --journal-book-height: 36rem;
  max-width: 72rem;
  margin: 0 auto;
}

.journal-flipbook-section {
  position: relative;
}

.journal-flipbook-section-eyebrow {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  background: hsl(var(--primary) / 0.1);
  color: hsl(var(--primary));
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.journal-flipbook-shell {
  position: relative;
  padding: 1rem;
  border-radius: 1.25rem;
  background:
    radial-gradient(circle at top, hsl(var(--primary) / 0.08), transparent 55%),
    linear-gradient(180deg, hsl(var(--card)), hsl(var(--background)));
  border: 1px solid hsl(var(--border) / 0.7);
  box-shadow: 0 20px 45px -24px rgb(0 0 0 / 0.25);
}

@media (min-width: 768px) {
  .journal-flipbook-shell {
    padding: 1.5rem;
  }
}

.journal-hidden-input {
  display: none;
}

.journal-opening-video-preload-host {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.journal-opening-video-preload {
  width: 1px;
  height: 1px;
}

/* ── Opening video (mywie2 experiment) ── */

.journal-opening-video-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  border-radius: inherit;
}

.journal-opening-video-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.journal-opening-video-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.88);
  border-radius: inherit;
}

.journal-opening-video {
  position: relative;
  z-index: 1;
  width: min(100%, 56rem);
  max-height: min(80vh, 36rem);
  border-radius: 0.75rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.55);
  background: #000;
  object-fit: contain;
}

.journal-opening-video-skip {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  border: 1px solid rgb(255 255 255 / 0.35);
  background: rgb(0 0 0 / 0.45);
  color: #fff;
  border-radius: 9999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.journal-opening-video-skip:hover {
  background: rgb(0 0 0 / 0.65);
  border-color: rgb(255 255 255 / 0.55);
}

/* ── Cover ── */

.journal-book-cover {
  position: relative;
  max-width: 28rem;
  margin: 0 auto;
  cursor: pointer;
  perspective: 1500px;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.journal-book-cover.is-opening {
  opacity: 0;
  transform: scale(0.95);
}

.journal-book-cover-inner {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  min-height: 34rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  background: linear-gradient(145deg, #8B4513 0%, #654321 50%, #4a3520 100%);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.35);
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.journal-book-cover:hover .journal-book-cover-inner {
  transform: rotateY(-5deg);
}

.journal-cover-noise {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  pointer-events: none;
}

.journal-cover-spine-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1.5rem;
  background: linear-gradient(to right, rgb(0 0 0 / 0.4), rgb(0 0 0 / 0.2), transparent);
  pointer-events: none;
}

.journal-book-cover::after {
  content: '';
  position: absolute;
  right: -0.5rem;
  top: 1rem;
  bottom: 1rem;
  width: 0.5rem;
  border-radius: 0 0.25rem 0.25rem 0;
  background: repeating-linear-gradient(to bottom, #f5f5dc 0, #f5f5dc 2px, #e8e8d0 2px, #e8e8d0 4px);
}

.journal-cover-edge {
  position: absolute;
  right: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 0.75rem;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.1) 30%, rgb(0 0 0 / 0.2));
  pointer-events: none;
}

.journal-book-cover-shadow {
  position: absolute;
  bottom: -1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 2rem;
  background: rgb(0 0 0 / 0.3);
  filter: blur(1rem);
  border-radius: 9999px;
}

.journal-cover-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
}

.journal-cover-family {
  color: rgb(253 230 138 / 0.9);
  font-size: 1.125rem;
  letter-spacing: 0.15em;
  font-family: var(--font-serif, Georgia, serif);
  text-shadow: 1px 1px 2px rgb(0 0 0 / 0.5);
}

.journal-cover-name {
  color: rgb(254 243 199);
  font-size: 1.875rem;
  font-family: var(--font-serif, Georgia, serif);
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgb(0 0 0 / 0.5);
}

.journal-cover-photo {
  position: relative;
  width: 6rem;
  height: 7rem;
  border-radius: 0.125rem;
  border: 2px solid rgb(253 230 138 / 0.5);
  background: rgb(253 230 138 / 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgb(253 230 138 / 0.7);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.25rem;
  cursor: pointer;
}

.journal-cover-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.journal-cover-photo-icon {
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}

.journal-cover-photo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.5);
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  font-size: 1rem;
}

.journal-cover-photo:hover .journal-cover-photo-overlay {
  opacity: 1;
}

.journal-cover-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 17.5rem;
  aspect-ratio: 1;
  margin: 0 auto;
}

.journal-cover-frame-image {
  position: absolute;
  inset: 1rem;
  border-radius: 0.25rem;
  overflow: hidden;
}

.journal-cover-frame-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.9;
}

.journal-cover-frame-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, rgb(120 53 15 / 0.2), transparent);
  pointer-events: none;
}

.journal-cover-corner {
  position: absolute;
  width: 2rem;
  height: 2rem;
  pointer-events: none;
  z-index: 2;
}

.journal-cover-corner-tl { top: 0.5rem; left: 0.5rem; border-top: 2px solid rgb(253 230 138 / 0.5); border-left: 2px solid rgb(253 230 138 / 0.5); border-radius: 0.25rem 0 0 0; }
.journal-cover-corner-tr { top: 0.5rem; right: 0.5rem; border-top: 2px solid rgb(253 230 138 / 0.5); border-right: 2px solid rgb(253 230 138 / 0.5); border-radius: 0 0.25rem 0 0; }
.journal-cover-corner-bl { bottom: 0.5rem; left: 0.5rem; border-bottom: 2px solid rgb(253 230 138 / 0.5); border-left: 2px solid rgb(253 230 138 / 0.5); border-radius: 0 0 0 0.25rem; }
.journal-cover-corner-br { bottom: 0.5rem; right: 0.5rem; border-bottom: 2px solid rgb(253 230 138 / 0.5); border-right: 2px solid rgb(253 230 138 / 0.5); border-radius: 0 0 0.25rem 0; }

.journal-cover-frame-border {
  position: absolute;
  inset: 0;
  border: 4px solid rgb(253 230 138 / 0.3);
  border-radius: 0.5rem;
  pointer-events: none;
}

.journal-cover-frame-border-inner {
  position: absolute;
  inset: 0.5rem;
  border: 1px solid rgb(253 230 138 / 0.2);
  border-radius: 0.25rem;
  pointer-events: none;
}

.journal-cover-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 2rem;
}

.journal-cover-story {
  color: rgb(254 243 199);
  font-size: 1.5rem;
  font-family: var(--font-serif, Georgia, serif);
  font-weight: 700;
  text-shadow: 2px 2px 4px rgb(0 0 0 / 0.5);
}

.journal-cover-tagline {
  color: rgb(253 230 138 / 0.7);
  font-size: 0.875rem;
  font-style: italic;
  margin-top: 0.25rem;
}

.journal-cover-seal {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 2px solid rgb(253 230 138 / 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #654321 0%, #4a3520 100%);
  color: rgb(254 243 199);
  font-family: var(--font-serif, Georgia, serif);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 0.3);
}

.journal-cover-hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgb(253 230 138 / 0.6);
  font-size: 0.875rem;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  z-index: 1;
}

/* ── Open book ── */

.journal-flipbook-open {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.journal-flipbook-open.is-opening {
  animation: journalFadeIn 0.5s ease forwards;
}

.journal-flipbook-open.is-closing {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

@keyframes journalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.journal-flipbook-open .journal-book-toolbar {
  display: flex;
}

.journal-book-toolbar {
  display: none;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.journal-book-controls {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
  .journal-book-controls {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    align-items: start;
  }
}

.journal-search-panel {
  padding: 1rem;
  border-radius: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.8);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.journal-book-stage {
  padding: 0.75rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgb(0 0 0 / 0.03), rgb(0 0 0 / 0.06));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35);
}

.journal-period-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
  padding: 0.375rem;
  border-radius: 0.875rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.8);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.journal-period-tab {
  border: none;
  background: transparent;
  border-radius: 0.625rem;
  padding: 0.75rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: all 0.2s;
  color: hsl(var(--muted-foreground));
}

.journal-period-tab:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.55);
}

.journal-period-tab.is-active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  box-shadow: 0 8px 20px -12px hsl(var(--primary));
}

.journal-search-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
  padding: 0.25rem;
  border-radius: 9999px;
  background: hsl(var(--muted) / 0.45);
}

.journal-search-mode {
  border: none;
  background: transparent;
  border-radius: 9999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  transition: all 0.2s;
}

.journal-search-mode.is-active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
}

.journal-search-wrap {
  position: relative;
  margin-bottom: 0.5rem;
}

.journal-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  opacity: 0.5;
  pointer-events: none;
}

.journal-search-input {
  width: 100%;
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 0.75rem 2.5rem;
  font-size: 0.9375rem;
  background: hsl(var(--background));
  transition: border-color 0.2s, box-shadow 0.2s;
}

.journal-search-input:focus {
  outline: none;
  border-color: hsl(var(--primary) / 0.45);
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.12);
}

.journal-search-clear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  background: transparent;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.journal-search-clear:hover {
  background: hsl(var(--muted));
}

.journal-search-results {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin: 0.25rem 0 0.5rem;
}

.journal-search-hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin: 0.35rem 0 0;
  line-height: 1.4;
}

.journal-search-year-note {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--primary));
  margin: 0.35rem 0 0;
  line-height: 1.4;
}

.journal-search-hits {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 0.75rem;
  background: hsl(var(--background));
}

.journal-search-hit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  border-bottom: 1px solid hsl(var(--border) / 0.55);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.journal-search-hit:last-child {
  border-bottom: none;
}

.journal-search-hit:hover,
.journal-search-hit.is-active {
  background: hsl(var(--primary) / 0.08);
}

.journal-search-hit.is-active {
  box-shadow: inset 3px 0 0 hsl(var(--primary));
}

.journal-search-hit-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  line-height: 1.35;
}

.journal-search-hit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.journal-search-hit-period {
  font-weight: 600;
  color: hsl(var(--primary));
}

.journal-search-hit-excerpt {
  font-size: 0.75rem;
  line-height: 1.45;
  color: hsl(var(--muted-foreground));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.journal-search-hits-more {
  padding: 0.55rem 0.85rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.35);
}

.journal-search-mark {
  background: hsl(var(--primary) / 0.18);
  color: inherit;
  border-radius: 0.15rem;
  padding: 0 0.1rem;
}

.journal-page-title .journal-search-mark {
  background: hsl(45 93% 47% / 0.35);
}

#journal-flipbook .journal-spread {
  position: relative;
  height: var(--journal-book-height);
  min-height: var(--journal-book-height);
  max-height: var(--journal-book-height);
  perspective: 2500px;
  filter: drop-shadow(0 24px 40px rgb(0 0 0 / 0.18));
}

#journal-flipbook .journal-page {
  position: absolute;
  top: 0;
  width: 50%;
  height: var(--journal-book-height);
  min-height: var(--journal-book-height);
  max-height: var(--journal-book-height);
  border: 1px solid rgb(120 53 15 / 0.12);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.35);
}

.journal-page-texture {
  position: absolute;
  inset: 0;
  opacity: 0.12;
  pointer-events: none;
}

#journal-flipbook .journal-page-left {
  left: 0;
  border-radius: 0.75rem 0 0 0.75rem;
  background: linear-gradient(to right, #fffdf7 0%, #fef8e8 100%);
}

#journal-flipbook .journal-page-right {
  right: 0;
  border-radius: 0 0.75rem 0.75rem 0;
  background: linear-gradient(to left, #fffdf7 0%, #fef8e8 100%);
}

.journal-page-spine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2rem;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent 0%, rgb(0 0 0 / 0.15) 45%, rgb(0 0 0 / 0.3) 50%, rgb(0 0 0 / 0.15) 55%, transparent 100%);
  pointer-events: none;
  z-index: 2;
}

.journal-page-content {
  position: relative;
  z-index: 1;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.journal-page-inner {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.625rem 1.25rem;
  overflow: hidden;
}

.journal-page-header {
  flex-shrink: 0;
  margin-bottom: 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid rgb(120 53 15 / 0.12);
}

.journal-page-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: rgb(120 53 15 / 0.25) transparent;
}

.journal-page-body::-webkit-scrollbar {
  width: 6px;
}

.journal-page-body::-webkit-scrollbar-thumb {
  background: rgb(120 53 15 / 0.22);
  border-radius: 9999px;
}

.journal-page-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.875rem;
  border-top: 1px solid rgb(120 53 15 / 0.12);
  background: linear-gradient(to top, rgb(255 251 235 / 0.95), transparent);
}

.journal-page-footer .journal-media-upload {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.journal-page-empty {
  height: 100%;
  min-height: 32rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgb(120 53 15 / 0.65);
  padding: 2rem;
}

.journal-no-results {
  width: 100%;
  min-height: 34rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  border: 1px solid hsl(var(--border) / 0.3);
  border-radius: 0.5rem;
  background: hsl(var(--card));
}

.journal-page-empty-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 9999px;
  background: linear-gradient(145deg, hsl(var(--primary) / 0.14), hsl(var(--primary) / 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5);
}

.journal-page-title {
  font-family: var(--font-serif, Georgia, serif);
  font-size: clamp(1.125rem, 1.8vw, 1.5rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.625rem;
  color: rgb(68 36 12);
}

.journal-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.journal-page-meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: rgb(120 53 15 / 0.08);
  color: rgb(120 53 15 / 0.85);
}

.journal-page-meta-chip--primary {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  font-weight: 600;
}

.journal-page-date {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.journal-page-text {
  font-size: 0.9375rem;
  line-height: 1.8;
  font-family: var(--font-serif, Georgia, serif);
  margin-bottom: 1rem;
  color: rgb(55 35 20 / 0.92);
}

/* ── Media ── */

.journal-medias-section {
  margin-top: 0.75rem;
}

.journal-medias-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.5rem;
}

.journal-medias-count {
  background: hsl(var(--muted));
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
}

.journal-medias-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.journal-media {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid hsl(var(--border) / 0.3);
  background: hsl(var(--muted) / 0.3);
}

.journal-media-delete-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border: none;
  border-radius: 9999px;
  background: rgb(0 0 0 / 0.65);
  color: #fff;
  font-size: 0.6875rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, transform 0.2s;
}

.journal-media:hover .journal-media-delete-btn,
.journal-media-delete-btn:focus-visible {
  opacity: 1;
}

.journal-media-delete-btn:hover {
  background: rgb(220 38 38 / 0.9);
  transform: scale(1.08);
}

.journal-media-audio .journal-media-delete-btn {
  opacity: 1;
}

#journal-flipbook[data-mode="user"] .journal-media-delete-btn {
  opacity: 0.9;
}

#journal-flipbook[data-mode="user"] .journal-media:hover .journal-media-delete-btn,
#journal-flipbook[data-mode="user"] .journal-media-delete-btn:focus-visible {
  opacity: 1;
}

.journal-media-zoomable {
  cursor: zoom-in;
}

.journal-media-image img {
  width: 100%;
  height: 9rem;
  object-fit: cover;
  display: block;
  transition: transform 0.3s;
  pointer-events: none;
}

.journal-media-image:hover img {
  transform: scale(1.05);
}

.journal-media-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(0 0 0 / 0.6), transparent);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
}

.journal-media-image:hover .journal-media-overlay {
  opacity: 1;
}

.journal-media-overlay span {
  color: white;
  font-size: 0.6875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-media-playable {
  cursor: pointer;
}

.journal-media-playable img {
  width: 100%;
  height: 8rem;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.journal-media-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.4);
  font-size: 0.875rem;
  color: white;
  width: 2rem;
  height: 2rem;
  margin: auto;
  border-radius: 9999px;
  background: hsl(var(--primary));
}

.journal-media-caption {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  right: 0.5rem;
  color: white;
  font-size: 0.6875rem;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.8);
}

.journal-media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.journal-media-lightbox.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.journal-media-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.9);
  cursor: zoom-out;
}

.journal-media-lightbox-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: min(96vw, 72rem);
  max-height: 92vh;
}

.journal-media-lightbox-media {
  display: block;
  max-width: 96vw;
  max-height: min(86vh, 52rem);
  width: auto;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.55);
  background: #000;
  object-fit: contain;
}

.journal-media-lightbox-media video,
video.journal-media-lightbox-media {
  width: min(96vw, 72rem);
  max-height: min(86vh, 52rem);
}

.journal-media-lightbox-caption {
  margin: 0;
  max-width: min(90vw, 40rem);
  color: rgb(255 255 255 / 0.9);
  font-size: 0.875rem;
  text-align: center;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
}

.journal-media-lightbox-close {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 9999px;
  background: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.journal-media-lightbox-close:hover {
  background: rgb(0 0 0 / 0.75);
  border-color: rgb(255 255 255 / 0.55);
}

body.journal-media-lightbox-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .journal-media-lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
    position: fixed;
  }
}

.journal-media-audio {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: linear-gradient(to right, hsl(var(--primary) / 0.1), hsl(var(--primary) / 0.05));
}

.journal-audio-btn {
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 9999px;
  border: none;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.6875rem;
}

.journal-audio-info {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
}

.journal-audio-bars {
  display: flex;
  gap: 2px;
  margin-top: 0.25rem;
}

.journal-audio-bars span {
  width: 3px;
  height: 0.75rem;
  background: hsl(var(--primary));
  border-radius: 1px;
  animation: journalBarPulse 0.8s ease-in-out infinite alternate;
}

.journal-audio-bars span:nth-child(2) { animation-delay: 0.1s; }
.journal-audio-bars span:nth-child(3) { animation-delay: 0.2s; }
.journal-audio-bars span:nth-child(4) { animation-delay: 0.3s; }

@keyframes journalBarPulse {
  from { height: 0.25rem; }
  to { height: 0.75rem; }
}

/* ── Media upload ── */

.journal-media-upload {
  margin-top: 0.75rem;
  padding: 0.875rem;
  border: 1px dashed rgb(120 53 15 / 0.22);
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 0.55);
}

.journal-media-upload-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgb(68 36 12);
  margin-bottom: 0.625rem;
}

.journal-media-upload-tabs {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.journal-media-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex: 1 1 0;
  min-width: 0;
  min-height: 3.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  border-radius: 0.625rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.journal-media-tab-icon {
  font-size: 0.8125rem;
  line-height: 1;
}

.journal-media-tab.is-active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
  box-shadow: 0 10px 24px -16px hsl(var(--primary));
  transform: translateY(-1px);
}

.journal-media-upload-hint {
  margin: 0;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.journal-media-upload-btn {
  width: 100%;
  border: 1px solid hsl(var(--border) / 0.5);
  background: hsl(var(--background));
  border-radius: 0.375rem;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: background 0.2s;
}

.journal-media-upload-btn:hover {
  background: hsl(var(--muted) / 0.5);
}

.journal-flipbook.is-uploading .journal-media-tab,
.journal-flipbook.is-uploading [data-action="cover-photo-upload"] {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

/* ── Music player ── */

.journal-music-player {
  position: relative;
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: linear-gradient(to right, rgb(254 243 199 / 0.5), rgb(255 251 235 / 0.5));
  border: 1px solid rgb(251 191 36 / 0.3);
  flex-shrink: 0;
}

.journal-music-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.journal-music-icon {
  font-size: 1rem;
}

.journal-music-meta {
  flex: 1;
  min-width: 0;
}

.journal-music-title {
  font-size: 0.875rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-music-artist {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-music-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.journal-music-play {
  width: 1.625rem;
  height: 1.625rem;
  border-radius: 9999px;
  border: none;
  background: rgb(245 158 11);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.6875rem;
}

.journal-music-play:hover {
  background: rgb(217 119 6);
}

.journal-music-progress,
.journal-music-volume {
  flex: 1;
  height: 0.25rem;
  cursor: pointer;
  accent-color: rgb(245 158 11);
}

.journal-music-volume {
  flex: 0 0 4rem;
}

.journal-music-mute {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem;
}

.journal-music-player--external {
  position: relative;
}

.journal-music-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-radius: 9999px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.journal-music-open:hover {
  opacity: 0.92;
}

.journal-music-open--inline {
  display: inline-flex;
  margin-top: 0.45rem;
  font-size: 0.75rem;
}

.journal-music-delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 9999px;
  background: rgb(0 0 0 / 0.45);
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}

.journal-playlist-modal::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.journal-audio-recorder-status {
  font-size: 0.9375rem;
  font-weight: 600;
  color: rgb(68 36 12);
  text-align: center;
}

.journal-audio-recorder-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  color: var(--primary, #b45309);
  letter-spacing: 0.04em;
}

.journal-audio-recorder-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.35rem;
  height: 2.5rem;
}

.journal-audio-recorder-bars span {
  display: block;
  width: 0.35rem;
  height: 0.75rem;
  border-radius: 9999px;
  background: var(--primary, #b45309);
  animation: journal-audio-record-pulse 0.9s ease-in-out infinite;
}

.journal-audio-recorder-bars span:nth-child(2) { animation-delay: 0.1s; }
.journal-audio-recorder-bars span:nth-child(3) { animation-delay: 0.2s; }
.journal-audio-recorder-bars span:nth-child(4) { animation-delay: 0.3s; }
.journal-audio-recorder-bars span:nth-child(5) { animation-delay: 0.4s; }

@keyframes journal-audio-record-pulse {
  0%, 100% { height: 0.6rem; opacity: 0.55; }
  50% { height: 2.1rem; opacity: 1; }
}

.journal-audio-recorder-preview {
  display: block;
  width: 100%;
}

.journal-audio-recorder-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.journal-audio-recorder-actions > button {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.journal-video-recorder-stage {
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #0b0b0b;
  aspect-ratio: 16 / 10;
}

.journal-video-recorder-live,
.journal-video-recorder-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b0b0b;
}

.journal-playlist-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.journal-playlist-divider::before,
.journal-playlist-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: hsl(var(--border));
}

/* ── Page flip animation ── */

@keyframes flipPageNext {
  0% { transform: rotateY(0deg); box-shadow: 0 0 20px rgb(0 0 0 / 0.3); }
  50% { transform: rotateY(-90deg); box-shadow: 0 0 40px rgb(0 0 0 / 0.4); }
  100% { transform: rotateY(-180deg); box-shadow: 0 0 20px rgb(0 0 0 / 0.3); }
}

@keyframes flipPagePrev {
  0% { transform: rotateY(0deg); box-shadow: 0 0 20px rgb(0 0 0 / 0.3); }
  50% { transform: rotateY(90deg); box-shadow: 0 0 40px rgb(0 0 0 / 0.4); }
  100% { transform: rotateY(180deg); box-shadow: 0 0 20px rgb(0 0 0 / 0.3); }
}

.journal-flip-overlay {
  position: absolute;
  top: 0;
  width: 50%;
  height: var(--journal-book-height);
  min-height: var(--journal-book-height);
  max-height: var(--journal-book-height);
  z-index: 20;
  overflow: hidden;
  transform-style: preserve-3d;
}

.journal-flip-right {
  right: 0;
  border-radius: 0 0.5rem 0.5rem 0;
  transform-origin: left center;
}

.journal-flip-left {
  left: 0;
  border-radius: 0.5rem 0 0 0.5rem;
  transform-origin: right center;
}

.journal-flip-next {
  animation: flipPageNext 0.8s ease-in-out forwards;
}

.journal-flip-prev {
  animation: flipPagePrev 0.8s ease-in-out forwards;
}

.journal-flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: linear-gradient(to left, #fffbeb, #fef3c7);
  border: 1px solid hsl(var(--border) / 0.3);
}

.journal-flip-back {
  transform: rotateY(180deg);
  background: linear-gradient(to right, #fffbeb, #fef3c7);
}

/* ── Navigation ── */

.journal-page-number {
  position: absolute;
  bottom: 1rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  z-index: 2;
}

.journal-page-number-left { left: 1rem; }
.journal-page-number-right { right: 1rem; }

.journal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.journal-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 9999px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.journal-nav-btn:hover:not(:disabled) {
  border-color: hsl(var(--primary) / 0.35);
  background: hsl(var(--primary) / 0.06);
  transform: translateY(-1px);
}

.journal-nav-btn-next:not(:disabled) {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: hsl(var(--primary));
}

.journal-nav-btn-next:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.92);
}

.journal-close-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 9999px;
  padding: 0.55rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.journal-close-btn:hover {
  background: hsl(var(--muted));
}

.journal-close-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: hsl(var(--muted));
  font-size: 0.6875rem;
}

.journal-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.journal-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  border: none;
  background: hsl(var(--muted));
  cursor: pointer;
  padding: 0;
}

.journal-dot.is-active {
  width: 2rem;
  background: hsl(var(--primary));
}

.journal-page-counter {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.journal-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 768px) {
  #journal-flipbook {
    --journal-book-height: 32rem;
  }

  .journal-book-controls {
    grid-template-columns: 1fr;
  }

  .journal-media-tab {
    min-height: 3rem;
    font-size: 0.625rem;
    padding: 0.35rem 0.15rem;
  }

  .journal-media-tab-icon {
    font-size: 1rem;
  }

  .journal-page-inner {
    padding: 1rem;
  }

  /* Keep media actions reachable on small screens */
  .journal-page-footer {
    position: relative;
    z-index: 2;
  }

  .journal-media-upload-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .journal-period-tabs {
    grid-template-columns: 1fr;
  }

  #journal-flipbook .journal-page-left,
  .journal-flip-left {
    display: none;
  }

  #journal-flipbook .journal-page-right,
  .journal-flip-right {
    width: 100%;
    border-radius: 0.5rem;
  }

  .journal-page-spine {
    display: none;
  }

  .journal-medias-grid {
    grid-template-columns: 1fr;
  }

  .journal-music-volume {
    display: none;
  }
}
