/* ── LiveInBooks — Novel Reading Experience ───────────────────── */

/* ── Layout ──────────────────────────────────────────────────── */
.novel-win {
  position: relative;
  width: min(900px, 96vw);
  height: 92vh;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: winIn .4s ease both;
}

.novel-header {
  padding: .8rem 1.4rem;
  border-bottom: 1px solid rgba(45,90,61,.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.novel-header-left {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.novel-header-title {
  font-family: var(--display);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .02em;
}
.novel-header-chapter {
  font-family: var(--body);
  font-size: .7rem;
  color: var(--text);
  opacity: .7;
  line-height: 1.3;
}
.novel-header-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.novel-header-mode {
  font-family: var(--sans);
  font-size: .55rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
}
.novel-header-wordcount {
  font-family: var(--sans);
  font-size: .55rem;
  letter-spacing: .04em;
  color: var(--faint);
}
.novel-header-right {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-left: auto;
}
.novel-save-btn {
  font-family: var(--sans);
  font-size: .65rem;
  letter-spacing: .04em;
  color: var(--faint);
  background: none;
  border: 1px solid rgba(45,90,61,.18);
  border-radius: 6px;
  padding: .3rem .7rem;
  cursor: pointer;
  transition: all .2s;
}
.novel-save-btn:hover {
  border-color: var(--green);
  color: var(--green);
}
.novel-save-btn:disabled {
  opacity: .5;
  cursor: default;
}
.novel-prompt-btn {
  font-family: var(--sans);
  font-size: .65rem;
  letter-spacing: .04em;
  color: var(--faint);
  background: none;
  border: 1px solid rgba(45,90,61,.18);
  border-radius: 6px;
  padding: .3rem .7rem;
  cursor: pointer;
  transition: all .2s;
}
.novel-prompt-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.novel-header-author-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.novel-header-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(45,90,61,.15);
  order: 2;
}
.novel-header-author {
  font-family: var(--sans);
  font-size: .65rem;
  color: var(--faint);
  letter-spacing: .06em;
  order: 1;
  text-transform: uppercase;
}

/* ── Prose Area ──────────────────────────────────────────────── */
.novel-prose {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.5rem 3rem;
  scroll-behavior: smooth;
}
.novel-prose-inner {
  max-width: 740px;
  margin: 0 auto;
}

.novel-chapter-heading {
  text-align: center;
  margin-bottom: 2.2rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid rgba(45,90,61,.1);
}
.novel-chapter-num {
  font-family: var(--sans);
  font-size: .6rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: .3rem;
}
.novel-chapter-name {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
}

/* Prose paragraphs */
.novel-prose-inner p {
  font-family: var(--body);
  font-size: 1.25rem;
  line-height: 1.85;
  color: #0a0806;
  margin-bottom: 1.2em;
  text-align: left;
}

/* Drop cap on the very first paragraph of the chapter */
.novel-prose-inner p.novel-drop-cap::first-letter {
  font-family: var(--display);
  font-size: 3.4em;
  float: left;
  line-height: .8;
  margin-right: .08em;
  margin-top: .05em;
  color: var(--green);
}

/* Paragraph fade-in */
@keyframes proseFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.novel-prose-inner p {
  animation: proseFadeIn .4s ease both;
}
.novel-stream-live {
  white-space: pre-wrap;
  line-height: 1.95;
}

/* Section break between beats */
.novel-beat-break {
  text-align: center;
  padding: 1rem 0;
  color: var(--faint);
  font-size: .8rem;
  letter-spacing: .3em;
}

/* ── Writing Indicator ───────────────────────────────────────── */
.novel-writing {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 0;
  max-width: 740px;
  margin: 0 auto;
}
.novel-writing-text {
  font-family: var(--body);
  font-size: .95rem;
  font-style: italic;
  color: var(--faint);
  transition: opacity .3s ease;
}
.novel-thinking-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.novel-thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: .4;
  animation: thinkDot 1.4s ease-in-out infinite;
}
.novel-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.novel-thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes thinkDot {
  0%, 60%, 100% { opacity: .3; transform: scale(.8); }
  30% { opacity: 1; transform: scale(1.1); }
}

/* ── Interaction Bar ─────────────────────────────────────────── */
.novel-input {
  flex-shrink: 0;
  border-top: 1px solid rgba(45,90,61,.1);
  background: #f5f1e8;
  overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
}
.novel-input.collapsed {
  max-height: 0;
  padding: 0 1.4rem;
  border-top-color: transparent;
}
.novel-input.active {
  max-height: 600px;
  padding: 1rem 1.4rem 1.2rem;
  overflow-y: auto;
}

.novel-input-inner {
  max-width: 740px;
  margin: 0 auto;
}

.novel-input-type-row {
  display: flex;
  gap: .35rem;
  margin-bottom: .5rem;
}
.novel-type-btn {
  font-family: var(--sans);
  font-size: .65rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  background: none;
  border: 1px solid rgba(45,90,61,.15);
  border-radius: 14px;
  padding: .25rem .7rem;
  cursor: pointer;
  transition: all .2s;
}
.novel-type-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.novel-type-btn.active {
  background: rgba(184,146,74,.1);
  border-color: var(--gold);
  color: var(--gold);
}

.novel-input-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  margin-bottom: .5rem;
}

.novel-suggest-btn {
  display: none;
  align-items: center;
  background: none;
  border: 1px solid rgba(45,90,61,.2);
  border-radius: 8px;
  padding: .55rem 1rem;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 500;
  color: var(--faint);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .2s;
  letter-spacing: .04em;
}
.novel-suggest-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.novel-suggest-btn.active {
  background: rgba(184,146,74,.08);
  border-color: var(--gold);
  color: var(--gold);
}

.novel-choice-prompt {
  font-family: var(--body);
  font-size: 1rem;
  font-style: italic;
  color: #1a1610;
  margin-bottom: .8rem;
  line-height: 1.5;
}

.novel-choices {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .6rem;
}
.novel-choice-btn {
  background: #fff;
  border: 1px solid rgba(45,90,61,.2);
  border-radius: 8px;
  padding: .65rem 1rem;
  font-family: var(--body);
  font-size: 1rem;
  color: #1a1610;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: all .2s;
}
.novel-choice-btn:hover {
  border-color: var(--gold);
  background: rgba(184,146,74,.06);
}
.novel-choice-btn:active {
  background: rgba(184,146,74,.12);
}

.novel-free-input {
  flex: 1;
  font-family: var(--body);
  font-size: 1rem;
  color: #1a1610;
  background: #fff;
  border: 1px solid rgba(45,90,61,.2);
  border-radius: 8px;
  padding: .55rem .8rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  min-height: 38px;
  max-height: 80px;
}
.novel-free-input:focus {
  border-color: var(--gold);
}
.novel-free-send {
  background: var(--me);
  color: rgba(240,235,215,.92);
  border: none;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: .04em;
  transition: opacity .2s;
  flex-shrink: 0;
}
.novel-free-send:hover { opacity: .85; }

.novel-retry-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(45,90,61,.2);
  border-radius: 8px;
  padding: .4rem .6rem;
  font-size: 1rem;
  color: var(--faint);
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s;
  line-height: 1;
}
.novel-retry-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Chapter Complete Card ───────────────────────────────────── */
.novel-complete {
  text-align: center;
  padding: 2.5rem 1rem;
  max-width: 740px;
  margin: 1rem auto 0;
  border-top: 1px solid rgba(45,90,61,.12);
}
.novel-complete-rule {
  width: 40px;
  height: 1px;
  background: var(--faint);
  margin: 0 auto 1.2rem;
}
.novel-complete-label {
  font-family: var(--sans);
  font-size: .6rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: .4rem;
}
.novel-complete-title {
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: .8rem;
}
.novel-complete-msg {
  font-family: var(--body);
  font-size: .95rem;
  font-style: italic;
  color: var(--faint);
  line-height: 1.5;
  margin-bottom: 1.2rem;
}
.novel-review-btn {
  font-family: var(--sans);
  font-size: .85rem;
  font-weight: 500;
  color: var(--green);
  background: #fff;
  border: 1.5px solid rgba(45,90,61,.3);
  border-radius: 20px;
  padding: .55rem 1.4rem;
  cursor: pointer;
  transition: all .18s;
}
.novel-review-btn:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.novel-review-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* ── Review overlay ─────────────────────────────────────────── */
.novel-review-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn .3s ease both;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.novel-review-wrap {
  width: 600px;
  max-width: calc(100vw - 2rem);
  height: 70vh;
  display: flex;
}
.novel-review-wrap .win {
  width: 100%;
  height: 100%;
}

/* ── Author side-chat panel ─────────────────────────────────── */
.novel-author-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(380px, 50%);
  height: 100%;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-left: 1px solid rgba(45,90,61,.12);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  animation: slideInRight .25s ease both;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.novel-author-close {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 10;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.06);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.novel-author-close:hover {
  background: rgba(0,0,0,.12);
}
.novel-author-chat-wrap {
  flex: 1;
  display: flex;
  min-height: 0;
}
.novel-author-chat-wrap .win {
  width: 100%;
  height: 100%;
}

/* Make author avatar pulse subtly to hint it's clickable */
.novel-header-avatar {
  transition: box-shadow .2s ease, transform .15s ease;
}
.novel-header-author-wrap:hover .novel-header-avatar {
  box-shadow: 0 0 0 3px rgba(45,90,61,.25);
  transform: scale(1.05);
}

/* ── Writer prompt viewer ───────────────────────────────────── */
.novel-prompt-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease both;
}
.novel-prompt-panel {
  width: min(720px, calc(100% - 2rem));
  max-height: 80%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.novel-prompt-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,.08);
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .03em;
}
.novel-prompt-close {
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--faint);
  padding: 0 .3rem;
}
.novel-prompt-copy {
  font-family: var(--sans);
  font-size: .65rem;
  letter-spacing: .04em;
  color: var(--faint);
  background: none;
  border: 1px solid rgba(45,90,61,.18);
  border-radius: 6px;
  padding: .25rem .6rem;
  cursor: pointer;
  transition: all .2s;
}
.novel-prompt-copy:hover {
  border-color: var(--green);
  color: var(--green);
}
.novel-prompt-close:hover { color: var(--text); }
.novel-prompt-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  margin: 0;
  font-family: var(--mono, monospace);
  font-size: .7rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
.novel-prose::-webkit-scrollbar {
  width: 6px;
}
.novel-prose::-webkit-scrollbar-track {
  background: transparent;
}
.novel-prose::-webkit-scrollbar-thumb {
  background: rgba(45,90,61,.15);
  border-radius: 3px;
}
.novel-prose::-webkit-scrollbar-thumb:hover {
  background: rgba(45,90,61,.25);
}
