/* ============================================================
   Books — reading journal (scrapbook / sketchbook)
   ============================================================ */

/* Full-screen architectural illustration — index page only (scoped via body class).
   The artwork (public/background2.png) covers the whole viewport, fixed while scrolling.
   A paper-colored veil sits on top (a touch denser at the top) so the header and card
   captions stay legible over the busy drawing. Swap public/background2.png to change it.
   Applied to index + the create/edit form pages so they share the journal
   atmosphere — and to the wallets and auth pages, which reuse the same look. */
body.c-books.a-index,
body.c-books.a-new,
body.c-books.a-edit,
body.c-wallets,
body.c-sessions,
body.c-registrations {
  background-color: #ece0c6;
  background-image:
    linear-gradient(180deg, rgba(238, 228, 205, 0.85) 0%, rgba(238, 228, 205, 0.71) 26%, rgba(238, 228, 205, 0.71) 100%),
    url("/background2.png");
  background-repeat: no-repeat, no-repeat;
  background-position: center, center;
  background-size: cover, cover;
  background-attachment: fixed, fixed;
}

/* Footer lives in the global layout; give it a paper halo on the journal page
   so it doesn't sink into the illustration. */
body.c-books .site-footer,
body.c-wallets .site-footer,
body.c-sessions .site-footer,
body.c-registrations .site-footer {
  color: var(--j-ink-soft);
  text-shadow: 0 0 8px rgba(240, 231, 209, 0.92), 0 1px 2px rgba(240, 231, 209, 0.85);
}

.journal {
  --j-ink:       #23201a;
  --j-ink-soft:  #4a4235;
  --j-ink-faint: #8a7d63;
  --j-accent:    #9c3b2e;
  --j-tape:      rgba(228, 214, 170, 0.6);
  --j-photo:     #fbf7ec;
  position: relative;
}

.journal__content {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Soft paper halo so dark ink text reads over the busy illustration */
.j-halo { text-shadow: 0 0 9px rgba(240, 231, 209, 0.95), 0 1px 2px rgba(240, 231, 209, 0.9); }

/* ---------- Handwritten header ---------- */
.journal-head {
  text-align: center;
  margin-bottom: 6px;
  padding: 12px 20px 4px;
  /* light backing that fades out, keeping the artwork visible around it */
  background: radial-gradient(ellipse 72% 135% at 50% 42%, rgba(240, 231, 209, 0.92), rgba(240, 231, 209, 0) 74%);
}
.journal-head h1 {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: clamp(42px, 7vw, 72px);
  line-height: 0.95;
  color: var(--j-ink);
  letter-spacing: 0.5px;
  margin: 0;
  text-shadow: 0 0 10px rgba(240, 231, 209, 0.98), 0 1px 2px rgba(240, 231, 209, 0.9);
}
.journal-head__sub {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.2rem;
  color: var(--j-ink-soft);
  margin: 6px 0 0;
  text-shadow: 0 0 8px rgba(240, 231, 209, 0.95), 0 1px 2px rgba(240, 231, 209, 0.9);
}
.journal-head__rule { display: block; width: 220px; height: 12px; margin: 10px auto 0; color: var(--j-ink-faint); }
.journal-head__count {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1rem;
  color: var(--j-ink-soft);
  margin: 12px 0 0;
  text-shadow: 0 0 8px rgba(240, 231, 209, 0.95), 0 1px 2px rgba(240, 231, 209, 0.9);
}
.journal-head__count strong { color: var(--j-ink); }

/* ---------- Toolbar (search + add) ---------- */
.journal-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 620px;
  margin: 28px auto 44px;
}
.journal-search {
  flex: 1; position: relative; display: flex; align-items: center;
  background: rgba(241, 233, 214, 0.62);
  border-radius: 8px;
  padding: 0 6px;
}
.journal-search__mag {
  position: absolute; left: 8px;
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif; font-size: 1.5rem;
  color: var(--j-ink-soft); pointer-events: none;
}
.journal-search input {
  width: 100%;
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.15rem;
  color: var(--j-ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--j-ink-faint);
  padding: 8px 34px;
  outline: none;
}
.journal-search input::placeholder { color: var(--j-ink-faint); }
.journal-search:focus-within input { border-bottom-color: var(--j-ink); }
.journal-search__clear {
  position: absolute; right: 2px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 1.2rem; line-height: 1;
  color: var(--j-ink-soft);
  background: transparent; border: none; cursor: pointer;
}
.journal-search__clear:hover { color: var(--j-ink); }
.journal-add {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  color: #efe4c8;
  background: var(--j-ink);
  border: none;
  cursor: pointer;
  padding: 8px 20px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(35, 32, 26, 0.2);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.journal-add:hover {
  color: #efe4c8;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(35, 32, 26, 0.24);
}

/* ---------- Entries grid (taped polaroids) ---------- */
.entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 44px 32px;
  justify-items: center;
}

/* Phones: always two books per row, each filling its cell */
@media (max-width: 500px) {
  .journal__content { padding: 0 14px; }
  .entries {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px 14px;
  }
  .entry { width: 100%; }
}

.entry {
  position: relative;
  width: 178px;
  background: var(--j-photo);
  padding: 12px 12px 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04), 0 10px 22px -12px rgba(60, 45, 25, 0.55);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.entry:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 30px -16px rgba(60, 45, 25, 0.5);
  z-index: 3;
}
/* tape — a clearly visible strip of washi holding the photo down */
.entry::before {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  transform: translateX(-50%);
  width: 64px; height: 22px;
  background: linear-gradient(160deg, rgba(228, 213, 166, 0.92), rgba(205, 187, 139, 0.86));
  border-left: 1px solid rgba(184, 166, 120, 0.5);
  border-right: 1px solid rgba(184, 166, 120, 0.5);
  box-shadow: 0 2px 4px rgba(60, 45, 25, 0.18);
}

.entry__photo-link { display: block; }
/* Uniform 3:4 frame for every card; the cover fills the whole frame
   (slight stretch instead of cropping or letterboxing). */
.entry__photo {
  position: relative;
  overflow: hidden;
  line-height: 0;
  aspect-ratio: 3 / 4;
  background: #f1e8d5;
}
.entry__photo img { width: 100%; height: 100%; object-fit: fill; display: block; }
.entry__photo--blank {
  line-height: normal;
  background: linear-gradient(150deg, #b9a17e, #967a52);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  color: #f3ead4;
}
.entry__photo--blank.t1 { background: linear-gradient(150deg, #8a5a3c, #5f3a24); }
.entry__photo--blank.t2 { background: linear-gradient(150deg, #5f7050, #3f4d34); }
.entry__photo--blank.t3 { background: linear-gradient(150deg, #46606f, #2f4350); }
.entry__photo--blank.t4 { background: linear-gradient(150deg, #7a5c74, #4f3a4c); }
.entry__blank-title { font-family: var(--font-display); font-size: 1rem; line-height: 1.15; }
.entry__blank-author { font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif; font-size: 0.85rem; margin-top: 8px; opacity: 0.85; }

.entry__caption { padding: 10px 6px 14px; text-align: center; }
.entry__title {
  display: block;
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--j-ink);
}
.entry__title:hover { color: var(--j-accent); }
.entry__author {
  display: block;
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--j-ink-soft);
  margin-top: 4px;
}
.entry__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.entry__genre {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  color: var(--j-accent);
  border: 1.5px solid var(--j-accent);
  border-radius: 20px;
  padding: 1px 10px;
  opacity: 0.8;
}
.entry__date { font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif; font-size: 0.8rem; color: var(--j-ink-faint); }

/* Ghost "new entry" card */
.entry--ghost {
  background: rgba(241, 233, 214, 0.6);
  box-shadow: none;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--j-ink-soft);
  border-radius: 2px;
  transform: none !important;
  text-decoration: none;
}
.entry--ghost::before { display: none; }
.entry--ghost span {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--j-ink-soft);
  text-align: center;
}
.entry--ghost:hover {
  transform: translateY(-4px) !important;
  border-color: var(--j-ink);
  background: rgba(243, 236, 220, 0.78);
  box-shadow: none;
}
.entry--ghost:hover span { color: var(--j-ink); }

/* ---------- Empty / no-results ---------- */
.journal-empty {
  max-width: 460px;
  margin: 56px auto;
  text-align: center;
  color: var(--j-ink-soft);
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  padding: 28px 24px;
  background: radial-gradient(ellipse 80% 120% at 50% 50%, rgba(240, 231, 209, 0.82), rgba(240, 231, 209, 0) 78%);
}
.journal-empty h2 {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 2rem;
  color: var(--j-ink);
  margin-bottom: 8px;
}
.journal-empty__add { display: inline-block; margin-top: 18px; }

/* ============================================================
   Show + form pages
   ============================================================ */

.book-detail {
  max-width: 720px;
  margin: 40px auto 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 40px;
  align-items: start;
}
.book-detail__cover img,
.book-detail__cover .book__cover--blank {
  border-radius: 3px 7px 7px 3px;
  box-shadow: var(--shadow-lg);
}
.book-detail__meta h1 { font-size: 2.2rem; margin: 0 0 6px; }
.book-detail__author { font-size: 1.1rem; color: var(--ink-soft); margin: 0 0 18px; }
.book-detail__actions { margin-top: 28px; display: flex; gap: 12px; }

@media (max-width: 620px) {
  .book-detail { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .book-detail__actions { justify-content: center; }
}

/* Form */
.book-form {
  max-width: 540px;
  margin: 40px auto 0;
  background: var(--paper);
  padding: 34px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.book-form .field { margin-bottom: 20px; }
.book-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.book-form input[type="text"],
.book-form input[type="file"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  padding: 11px 14px;
  background: #fffdf8;
  border: 1px solid #e0d4bd;
  border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.book-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 106, 77, 0.15);
}
.book-form .form-actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; }

.form-errors {
  background: #f7e3dd;
  border: 1px solid #e6c3b8;
  color: #8c3a26;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  font-size: 0.9rem;
}
.form-errors ul { margin: 6px 0 0; padding-left: 20px; }

/* ============================================================
   Book detail modal (antd shell + journal content).
   Rendered in a body-level portal, so styles use literal colours
   (the .journal --j-* custom props aren't in scope here).
   ============================================================ */

.book-modal { max-width: calc(100vw - 32px); }

.modal__sheet {
  display: grid;
  grid-template-columns: 1.02fr 1fr;
  max-height: min(640px, 88vh);
  overflow: hidden;
  border-radius: 10px;
  background: #f6efdd;
}

/* Left: the cover as a taped polaroid on a paper stage */
.modal__visual {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 46px 40px;
  background: radial-gradient(120% 90% at 50% 20%, #f3ead4 0%, #e6d8ba 100%);
}
.modal__polaroid {
  position: relative;
  background: #fbf7ec;
  padding: 12px 12px 14px;
  max-width: 256px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.06), 0 18px 42px -18px rgba(60, 45, 25, 0.7);
}
.modal__polaroid::before {
  content: "";
  position: absolute;
  top: -11px; left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 88px; height: 24px;
  background: rgba(228, 214, 170, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
/* Cover shown in full, never cropped */
.modal__cover {
  display: block;
  max-width: 100%;
  max-height: 56vh;
  width: auto;
  height: auto;
}
.modal__polaroid .entry__photo--blank { width: 232px; }

/* Right: handwritten details */
.modal__body {
  position: relative;
  padding: 46px 42px 38px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  color: #23201a;
}
.modal__close {
  position: absolute;
  top: 18px; right: 18px;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  line-height: 1;
  color: #4a4235;
  background: rgba(60, 44, 30, 0.06);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.modal__close:hover { background: rgba(60, 44, 30, 0.12); color: #23201a; transform: rotate(90deg); }
.modal__close:focus { outline: none; }
.modal__close:focus-visible { outline: 2px solid #9c3b2e; outline-offset: 2px; }

.modal__title {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1;
  color: #23201a;
  margin: 4px 56px 8px 0;
}
.modal__author {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.1rem;
  color: #4a4235;
  margin: 0 0 16px;
}
.modal__genre {
  align-self: flex-start;
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: #9c3b2e;
  border: 1.5px solid #9c3b2e;
  border-radius: 20px;
  padding: 2px 12px;
}
.modal__rule {
  display: block;
  width: 200px; height: 12px;
  margin: 24px 0;
  color: #8a7d63;
}
.modal__meta { margin: 0; }
.modal__meta dt {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: #7d7259;
}
.modal__meta dd {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  margin: 2px 0 0;
  font-size: 1.1rem;
  color: #23201a;
}

.modal__actions {
  margin-top: auto;
  padding-top: 30px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.modal__actions form { margin: 0; }
.modal__actions .btn {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
}
.modal__actions a.btn {
  background: #23201a;
  color: #efe4c8;
  border-color: #23201a;
}
.modal__actions a.btn:hover { background: #171410; color: #efe4c8; }

@media (max-width: 680px) {
  .modal__sheet {
    grid-template-columns: 1fr;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal__visual { padding: 34px 32px 10px; }
  .modal__cover { max-height: 42vh; }
  .modal__body { padding: 28px 28px 32px; }
}

/* ============================================================
   Cozy book form (React) — floating labels + micro-interactions
   ============================================================ */

.cozy-form {
  max-width: 540px;
  margin: 40px auto 0;
  background: var(--paper);
  padding: 36px 38px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  animation: formIn 0.55s var(--ease) both;
}

@keyframes formIn {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.cozy-form.is-shaking { animation: formShake 0.45s var(--ease); }
@keyframes formShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-8px); }
  38% { transform: translateX(7px); }
  58% { transform: translateX(-5px); }
  78% { transform: translateX(3px); }
}

/* Each field rises into place with a small stagger (animationDelay set inline) */
.cf-field {
  position: relative;
  margin-bottom: 22px;
  animation: fieldIn 0.5s var(--ease) both;
}
@keyframes fieldIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.cf-field input,
.cf-field select {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  padding: 23px 14px 9px;
  background: #fffdf8;
  border: 1px solid #e0d4bd;
  border-radius: var(--radius-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  appearance: none;
}
.cf-field input:focus,
.cf-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(192, 106, 77, 0.15);
}

/* Floating label: rests inside the field, lifts up on focus / when filled */
.cf-field > label {
  position: absolute;
  left: 15px;
  top: 16px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-faint);
  pointer-events: none;
  transform-origin: left center;
  transition: transform 0.18s var(--ease), color 0.18s var(--ease);
}
.cf-field.is-active > label,
.cf-field input:focus + label,
.cf-field select:focus + label {
  transform: translateY(-10px) scale(0.74);
  color: var(--accent-deep);
  font-weight: 600;
}

/* Animated underline that grows from the centre on focus */
.cf-underline {
  position: absolute;
  left: 50%; right: 50%;
  bottom: 0; height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transition: left 0.25s var(--ease), right 0.25s var(--ease);
}
.cf-field input:focus ~ .cf-underline,
.cf-field select:focus ~ .cf-underline { left: 8px; right: 8px; }

/* Genre as a row of selectable chips instead of a native <select> */
.cf-genres {
  margin-bottom: 22px;
  animation: fieldIn 0.5s var(--ease) both;
}
.cf-genres__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 10px;
}
.cf-genres__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.cf-chip {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 8px 15px;
  background: #fffdf8;
  border: 1px solid #e0d4bd;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s var(--ease),
              color 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.cf-chip:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.cf-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cf-chip.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff7ef;
  box-shadow: 0 4px 12px rgba(160, 84, 58, 0.28);
  animation: chipPop 0.28s var(--ease);
}
@keyframes chipPop {
  0%   { transform: scale(0.9); }
  55%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
.cf-genres.is-error .cf-error { max-height: 40px; opacity: 1; margin-top: 8px; }

/* Inline field error — slides + fades in */
.cf-error {
  max-height: 0;
  overflow: hidden;
  color: #a4543a;
  font-size: 0.82rem;
  opacity: 0;
  transition: max-height 0.25s var(--ease), opacity 0.25s var(--ease), margin 0.25s var(--ease);
}
.cf-field.is-error .cf-error { max-height: 40px; opacity: 1; margin-top: 6px; }
.cf-field.is-error input,
.cf-field.is-error select { border-color: #d08163; }

.cf-form-error {
  background: #f7e3dd;
  border: 1px solid #e6c3b8;
  color: #8c3a26;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.9rem;
  animation: fieldIn 0.3s var(--ease) both;
}

/* ---------- Cover picker ---------- */
.cf-cover {
  position: relative;
  margin-bottom: 22px;
  animation: fieldIn 0.5s var(--ease) both;
}
.cf-cover__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 8px;
}
.cf-cover__drop {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: #fffdf8;
  border: 1.5px dashed #d8c8aa;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--ease);
}
.cf-cover__drop:hover {
  border-color: var(--accent);
  background: #fff;
  transform: translateY(-1px);
}
.cf-cover__icon {
  display: grid;
  place-items: center;
  width: 56px; height: 76px;
  flex: none;
  font-size: 1.6rem;
  color: var(--ink-faint);
  background: var(--bg-deep);
  border-radius: 4px 6px 6px 4px;
}
.cf-cover__preview {
  width: 56px; height: 76px;
  flex: none;
  object-fit: cover;
  border-radius: 4px 6px 6px 4px;
  box-shadow: var(--shadow-sm);
  animation: coverPop 0.4s var(--ease) both;
}
@keyframes coverPop {
  from { opacity: 0; transform: scale(0.86) rotate(-3deg); }
  to   { opacity: 1; transform: none; }
}
.cf-cover__hint {
  font-size: 0.9rem;
  color: var(--ink-soft);
  word-break: break-word;
}

/* ---------- Submit button states ---------- */
.cf-actions {
  margin-top: 30px;
  display: flex;
  gap: 12px;
  align-items: center;
  animation: fieldIn 0.5s var(--ease) both;
}
.cf-submit {
  position: relative;
  min-width: 188px;
  justify-content: center;
  overflow: hidden;
}
.cf-submit__spinner,
.cf-submit__check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
}
.cf-submit__spinner {
  width: 18px; height: 18px;
  inset: auto;
  border: 2px solid rgba(255, 247, 239, 0.4);
  border-top-color: #fff7ef;
  border-radius: 50%;
}
.cf-submit__label { transition: opacity 0.2s var(--ease); }

.cf-submit--submitting { pointer-events: none; }
.cf-submit--submitting .cf-submit__label { opacity: 0; }
.cf-submit--submitting .cf-submit__spinner { opacity: 1; animation: spin 0.7s linear infinite; }

.cf-submit--success { background: var(--sage); box-shadow: 0 6px 16px rgba(138, 154, 123, 0.4); pointer-events: none; }
.cf-submit--success .cf-submit__label { opacity: 0; }
.cf-submit--success .cf-submit__check { opacity: 1; font-size: 1.3rem; animation: checkPop 0.4s var(--ease) both; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes checkPop {
  0% { opacity: 0; transform: scale(0.3); }
  60% { transform: scale(1.18); }
  100% { opacity: 1; transform: scale(1); }
}

.cozy-form.is-done { transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .cozy-form, .cf-field, .cf-cover, .cf-genres, .cf-actions,
  .cf-cover__preview, .cf-form-error, .cf-chip.is-selected { animation: none; }
  .cozy-form.is-shaking { animation: none; }
}

@media (max-width: 560px) {
  .cozy-form { padding: 28px 22px 26px; margin-top: 24px; }
  .cf-actions { flex-direction: column-reverse; align-items: stretch; }
  .cf-actions .btn { justify-content: center; }
}

/* ============================================================
   Journal styling for the book form (new / edit)
   — reuses the .cozy-form structure/animations, re-skinned to match
   the reading journal: sepia paper, handwritten fields, ink accents.
   ============================================================ */
.journal__content--narrow { max-width: 620px; }

/* The form as a paper page taped onto the desk */
body.c-books .cozy-form {
  --accent: #9c3b2e;
  --accent-deep: #7d2f24;
  position: relative;
  max-width: 560px;
  background: #f6efdd;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05), 0 14px 32px -16px rgba(60, 45, 25, 0.55);
}
body.c-books .cozy-form::before {
  content: "";
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  width: 128px; height: 26px;
  background: rgba(228, 214, 170, 0.6);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Fields, chips & cover drop — sepia paper with handwritten type */
body.c-books .cf-field input,
body.c-books .cf-field select,
body.c-books .cf-chip,
body.c-books .cf-cover__drop {
  background: #fbf7ec;
  border-color: #cdbf9e;
}
body.c-books .cf-field input,
body.c-books .cf-field select {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.05rem;
}
body.c-books .cf-field > label,
body.c-books .cf-chip,
body.c-books .cf-cover__hint { font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif; }
body.c-books .cf-genres__label,
body.c-books .cf-cover__label {
  font-family: "Kalam", ui-rounded, "Segoe UI", sans-serif;
  color: #7d2f24;
}
body.c-books .cf-field input:focus,
body.c-books .cf-field select:focus,
body.c-books .cf-cover__drop:hover {
  border-color: #9c3b2e;
  box-shadow: 0 0 0 3px rgba(156, 59, 46, 0.15);
}
/* selected genre chip — needs equal-or-higher specificity than the paper
   override above, otherwise the fill is lost and the light text vanishes */
body.c-books .cf-chip.is-selected {
  background: #9c3b2e;
  border-color: #9c3b2e;
  color: #fff7ef;
}

/* Submit — ink button like "додати книжку"; cancel handwritten */
body.c-books .cf-submit.btn-primary {
  background: #23201a;
  color: #efe4c8;
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
}
body.c-books .cf-submit.btn-primary:hover { background: #171410; color: #efe4c8; }
body.c-books .cf-submit--success { background: var(--sage); }
body.c-books .cf-actions .btn-ghost {
  font-family: "Caveat", ui-rounded, "Segoe UI", sans-serif;
  font-size: 1.25rem;
}

/* ============================================================
   Toasts — server flash rendered as cozy animated popups
   ============================================================ */
.toasts {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none; /* container is click-through; toasts opt back in */
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  max-width: min(92vw, 380px);
  padding: 13px 14px 13px 16px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--sage);
  box-shadow: var(--shadow-lg);
  font-size: 0.95rem;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateX(24px); }

.toast--notice { border-left-color: var(--sage); }
.toast--alert  { border-left-color: var(--accent); }

.toast__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff7ef;
  background: var(--sage);
}
.toast--alert .toast__icon { background: var(--accent); }

.toast__text { flex: 1; line-height: 1.4; }

.toast__close {
  flex: none;
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.toast__close:hover { background: rgba(60, 44, 30, 0.08); color: var(--ink); }

@media (max-width: 560px) {
  .toasts { left: 14px; right: 14px; top: 14px; align-items: stretch; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.2s var(--ease); transform: none; }
  .toast.is-in, .toast.is-out { transform: none; }
}
