:root {
  --bg: #101610;
  --ink: #1c140c;
  --paper: #f4ecd8;
  --paper-edge: #e4d7b8;
  --muted: #8aa38a;
  --lime: #c6f27a;
  --green: #2ecc71;
  --line: rgba(244, 236, 216, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(46, 204, 113, 0.16), transparent 55%),
    var(--bg);
  color: var(--paper);
  font-family: "Space Grotesk", sans-serif;
}

body { padding: 1.5rem 1rem 3rem; }

.room {
  max-width: 980px;
  margin: 0 auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.home {
  color: var(--green);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0.2rem 0 0.35rem;
  font-family: "Literata", serif;
  font-weight: 650;
  font-size: 2.4rem;
  letter-spacing: -0.03em;
}

.lede {
  margin: 0;
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.45;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#pause {
  appearance: none;
  margin: 0;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

#pause.paused {
  border-color: var(--lime);
  color: var(--lime);
}

#pause:hover { border-color: var(--green); }

.meter { margin: 0 0 1.25rem; }

.meter-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.meter-track {
  height: 0.5rem;
  border-radius: 999px;
  background: rgba(244, 236, 216, 0.12);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--green);
}

.meter.reached .meter-fill { background: var(--lime); }

.meter-note {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.meter.reached .meter-note { color: var(--lime); }

.status {
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--lime);
  font-size: 0.85rem;
  white-space: nowrap;
}

.persona-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.persona {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  text-align: left;
  cursor: pointer;
  max-width: 220px;
}

.persona strong { display: block; font-size: 0.95rem; }
.persona span { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.78rem; line-height: 1.3; }

.persona.active,
.persona:hover,
.persona.composing {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.08);
}

.persona.composing { border-style: dashed; }

.custom-form {
  max-width: 40rem;
  margin: 0 0 1.25rem;
}

.custom-form label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.custom-form textarea {
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  line-height: 1.45;
}

.custom-form textarea:focus {
  outline: none;
  border-color: var(--green);
}

.custom-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.45rem;
}

.custom-count { color: var(--muted); font-size: 0.78rem; }

.custom-form button {
  appearance: none;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  cursor: pointer;
}

.custom-form button:hover { background: rgba(46, 204, 113, 0.08); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 1.25rem;
  align-items: start;
}

.book {
  background: var(--paper);
  color: var(--ink);
  min-height: 60vh;
  padding: 2.4rem 2.2rem 3rem;
  border-radius: 2px 12px 12px 2px;
  box-shadow: -14px 0 0 var(--paper-edge), 0 18px 50px rgba(0, 0, 0, 0.28);
}

.empty, .draft {
  font-family: "Literata", serif;
  font-size: 1.15rem;
  line-height: 1.6;
}

.empty { color: #8a7356; font-style: italic; }

.para, .draft {
  font-family: "Literata", serif;
  font-size: 1.18rem;
  line-height: 1.65;
  margin: 0 0 1.15rem;
}

.draft { color: #6d5a42; }

.chat-prose {
  color: #3a8014;
  font-family: "Comic Sans MS", "Comic Sans", "Comic Neue", cursive;
}

.chat-emote {
  height: 1.5em;
  vertical-align: middle;
  margin: 0 0.1em;
}

.shelf h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.shelf-note {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

#shelf {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chapter {
  position: relative;
}

.chapter .open {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem 1.9rem;
  cursor: pointer;
  font: inherit;
}

.chapter.current .open { border-color: var(--green); }
.chapter .open strong { display: block; font-weight: 500; }
.chapter .open small { display: block; color: var(--muted); margin-top: 0.15rem; }

.chapter .trash {
  position: absolute;
  right: 0.28rem;
  bottom: 0.22rem;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0.28rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chapter .trash svg { width: 100%; height: 100%; display: block; }
.chapter .trash:hover { color: var(--paper); background: rgba(244, 236, 216, 0.08); }

.shelf .none { color: var(--muted); font-size: 0.85rem; }

.credits {
  margin-top: 1.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.credits p { margin: 0.2rem 0; }

.credits a {
  color: var(--green);
  text-decoration: none;
}

.credits a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  .top { flex-direction: column; align-items: flex-start; }
  .status { white-space: normal; }
  .layout { grid-template-columns: 1fr; }
  .book { padding: 1.5rem 1.15rem 2rem; }
  h1 { font-size: 2rem; }
}
