/* 读书页 Silas 浮层对话 */

.reading-chat-panel {
  position: fixed;
  z-index: 220;
  display: flex;
  flex-direction: column;
  min-width: 280px;
  min-height: 220px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.reading-chat-panel.hidden {
  display: none !important;
}

.reading-chat-panel.is-dragging {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
  cursor: grabbing;
}

.reading-chat-panel.is-dragging .reading-chat-head {
  cursor: grabbing;
}

.reading-chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  background: var(--ui-accent-bar, #efbfd6);
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.reading-chat-drag {
  flex-shrink: 0;
  border: none;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  width: 28px;
  height: 32px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: rgba(50, 50, 50, 0.85);
  cursor: grab;
  touch-action: none;
}

.reading-chat-drag:active {
  cursor: grabbing;
}

.reading-chat-head-text {
  min-width: 0;
  flex: 1;
}

.reading-chat-title {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  color: #333;
}

.reading-chat-context {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(60, 60, 60, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reading-chat-head-actions {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
}

.reading-chat-head-actions.hidden {
  display: none !important;
}

.reading-chat-head-btn {
  border: none;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.reading-chat-close {
  border: none;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.reading-chat-messages {
  flex: 1 1 auto;
  min-height: 80px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.reading-chat-empty {
  margin: auto;
  text-align: center;
  color: rgba(100, 100, 100, 0.85);
  font-size: 0.88rem;
}

.reading-chat-bubble {
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.reading-chat-bubble.user {
  align-self: flex-end;
  background: var(--ui-accent-btn-hot, #c2185b);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.reading-chat-bubble.assistant {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.06);
  color: #222;
  border-bottom-left-radius: 4px;
}

.reading-chat-bubble[data-message-id] {
  cursor: context-menu;
  touch-action: manipulation;
  user-select: text;
}

.reading-chat-compose {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.98);
}

.reading-chat-compose .reading-chat-input {
  flex: 1;
  min-width: 0;
}

.reading-chat-compose .reading-chat-send {
  flex-shrink: 0;
  margin-bottom: 2px;
}

.reading-chat-edit-bar {
  flex: 0 0 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(194, 24, 91, 0.08);
  border: 1px solid rgba(194, 24, 91, 0.18);
  box-sizing: border-box;
}

.reading-chat-edit-bar.hidden {
  display: none !important;
}

.reading-chat-edit-bar-text {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: rgba(80, 40, 55, 0.92);
}

.reading-chat-edit-cancel {
  flex-shrink: 0;
  border: none;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  color: #555;
  cursor: pointer;
}

#reading-chat-msg-action-actions .hidden {
  display: none !important;
}

.reading-chat-panel.reading-chat-readonly .reading-chat-compose {
  display: none;
}

.reading-chat-input {
  min-height: 72px;
  max-height: 140px;
  resize: none;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}

.reading-chat-send {
  padding: 10px 16px;
  font-size: 0.85rem;
}

.reading-chat-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0.35;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, 0.35) 50%);
  border-bottom-right-radius: 12px;
}

.reading-silas-nav {
  position: absolute;
  right: 14px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 18;
  width: 48px;
  height: 48px;
  padding: 3px;
  border: 2px solid var(--ui-accent-btn-hot, #c2185b);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  cursor: grab;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
}

.reading-silas-nav.is-dragging {
  cursor: grabbing;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.reading-silas-nav.hidden {
  display: none !important;
}

.reading-silas-nav img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.reading-silas-nav-fallback {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ui-accent-btn-hot, #c2185b);
}

#reading-reader-pane {
  position: relative;
  flex: 1;
  min-height: 0;
}

.reading-chat-thread-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  border-radius: 16px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.65);
  cursor: pointer;
}

.reading-chat-thread-card {
  display: flex;
  align-items: stretch;
}

@media (max-width: 480px) {
  .reading-chat-panel {
    min-height: 240px;
  }

  .reading-chat-input {
    min-height: 64px;
  }
}
