.theater-page {
  display: none;
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(22px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--paper);
  flex-direction: column;
}

.theater-page.active {
  display: flex;
}

.bookshelf-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 24px 16px;
  margin-top: 17px;
}

.book-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  background-color: #e5e5e1;
  border-radius: 4px 8px 8px 4px;
  box-shadow: inset 4px 0 10px rgba(0,0,0,0.05), 2px 4px 8px rgba(0,0,0,0.1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.05);
  transition: transform 0.2s;
}

.book-item:active .book-cover {
  transform: scale(0.96);
}

.book-cover::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.4);
}

.book-title-display {
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.book-name {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.3;
}

body.show-theater .home-shell {
  display: none;
}

body.show-theater .theater-page.active {
  display: flex;
}

body.show-thread .theater-page.active {
  display: none;
}

/* Book Reading Experience overrides */
.theater-reading-page {
  background-color: #fcfaf5;
  color: #2b2826;
  font-family: "LXGW WenKai", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
}

.theater-reading-page .thread-heading {
  background: rgba(252, 250, 245, 0.9);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.theater-reading-page .thread-name {
  font-size: 16px;
  font-weight: bold;
  color: #3e3832;
  font-family: inherit;
}

.theater-reading-page .message-area {
  padding: 24px 20px;
  gap: 28px;
}

.theater-reading-page .message {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.theater-reading-page .message.outgoing {
  flex-direction: column;
  align-self: flex-start;
}

.theater-reading-page .message.outgoing .message-content {
  align-items: flex-start;
}

.theater-forum-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.theater-forum-author {
  font-size: 15px;
  font-weight: 700;
  color: #46423e;
  font-family: "LXGW WenKai", "Source Han Serif SC", serif;
}

.theater-forum-meta {
  font-size: 11px;
  color: #a39c94;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
}

.theater-reading-page .message-bubble {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-size: 16px;
  line-height: 1.85;
  color: #2b2826;
  text-indent: 0;
  text-align: left;
  font-family: "LXGW WenKai", "Source Han Serif SC", "Noto Serif CJK SC", serif;
}

.theater-reading-page .message.outgoing .message-bubble {
  color: #383431;
  text-indent: 0;
  text-align: left;
  width: 100%;
}

.theater-reading-form {
  background: #fcfaf5;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 10px 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto !important;
  gap: 12px;
  border-radius: 0;
  align-items: center;
}

.theater-tool-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: #777;
  cursor: pointer;
  padding: 0;
}

.theater-tool-btn:hover {
  color: #333;
}

.theater-tool-btn svg {
  width: 22px;
  height: 22px;
}

.theater-continue-btn {
  background: #46423e;
  color: #fff;
  border: none;
  border-radius: 17px;
  padding: 0 16px;
  height: 34px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.2s;
  white-space: nowrap;
}

.theater-continue-btn:hover {
  background: #2b2826;
}

.theater-toc-empty {
  text-align: center;
  padding: 40px 0;
  color: #a39c94;
  font-size: 14px;
}

.theater-reading-form .message-input-wrap {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0;
  height: auto;
  padding-bottom: 4px;
}

.theater-reading-form .message-input-wrap:focus-within {
  border-bottom-color: #888;
  background: transparent;
}

.theater-reading-form .message-input {
  padding: 0 4px;
  font-family: inherit;
  font-size: 15px;
}

/* Theater Menu Modal (Bottom Sheet) */
.theater-menu-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.theater-menu-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.theater-menu-sheet {
  background: var(--paper);
  width: min(100%, 760px);
  margin: 0 auto;
  border-radius: 20px 20px 0 0;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

.theater-menu-modal.open .theater-menu-sheet {
  transform: translateY(0);
}

/* Edit/Delete Buttons in Meta */
.theater-meta-btn {
  background: transparent;
  border: none;
  color: #a39c94;
  font-size: 11px;
  cursor: pointer;
  margin-left: 8px;
  padding: 0;
  text-decoration: underline;
}

.theater-meta-btn:hover {
  color: #666;
}

/* Swipe Controls */
.theater-swipe-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.05);
}

.theater-swipe-btn {
  background: #f0ebe1;
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: #5c4d3c;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.theater-swipe-btn:hover {
  background: #e6dfd1;
}

.theater-swipe-counter {
  font-size: 12px;
  color: #a39c94;
  font-family: -apple-system, sans-serif;
}

.theater-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.theater-menu-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.theater-menu-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.theater-menu-content {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.theater-setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theater-setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.theater-cover-edit {
  width: 100px;
  height: 150px;
  background: #e5e5e1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.theater-cover-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.theater-cover-placeholder {
  font-size: 12px;
  color: #888;
  text-align: center;
  padding: 8px;
  position: absolute;
  pointer-events: none;
}

.theater-setting-input,
.theater-setting-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d2d2cd;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.theater-setting-input:focus,
.theater-setting-textarea:focus {
  border-color: #777;
}

.theater-setting-textarea {
  resize: vertical;
  min-height: 80px;
}

.theater-wb-dropdown-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d2d2cd;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.theater-wb-dropdown-list {
  display: flex;
  flex-direction: column;
  border: 1px solid #d2d2cd;
  border-radius: 8px;
  background: var(--white);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}

.theater-wb-dropdown-list[hidden] {
  display: none;
}

.theater-wb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.theater-wb-item:last-child {
  border-bottom: none;
}

.theater-wb-item:hover {
  background: #f7f7f5;
}

.theater-wb-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.theater-wb-name {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theater-chapter-title {
  font-size: 22px;
  font-weight: bold;
  margin: 0 0 20px 0;
  text-align: center;
  color: #2b2826;
  font-family: inherit;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
  padding-bottom: 12px;
}

.theater-paragraph {
  margin: 0 0 16px 0;
  text-indent: 2em;
  line-height: 1.8;
  font-size: 16px;
  color: #2b2826;
  text-align: justify;
}

.theater-toc-item {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 15px;
  color: #46423e;
  cursor: pointer;
  transition: background-color 0.2s;
  font-family: inherit;
}

.theater-toc-item:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.theater-toc-item:last-child {
  border-bottom: none;
}

/* AI Waiting and Response Styles */
.theater-reading-page .message.waiting-msg .message-bubble {
  color: #8a89a1;
  font-style: italic;
  animation: theater-wait-pulse 1.8s ease-in-out infinite;
}

.theater-reading-page .message.error .message-bubble {
  color: #c04848;
  font-size: 14px;
  background: rgba(192, 72, 72, 0.05) !important;
  padding: 10px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(192, 72, 72, 0.2);
}

@keyframes theater-wait-pulse {
  50% { opacity: 0.5; transform: scale(0.98); }
}

/* Scrollbar for reading area */
.theater-reading-page .message-area::-webkit-scrollbar {
  width: 6px;
}

.theater-reading-page .message-area::-webkit-scrollbar-track {
  background: transparent;
}

.theater-reading-page .message-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.theater-reading-page .message-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.1);
}
