/**
 * Lectura — shared drawer + chat + notes styles.
 * Single source of truth for presentation and remote. Do not duplicate.
 * Used by: plugin/lectura/lectura.css (@import) and remote/index.html (link).
 */

/* Utility: hide when auth/state is resolved (remote must have this so "Checking sign-in..." can be hidden) */
.rf-hidden {
  display: none !important;
}

/* Chat auth loading (shown until first onAuthStateChanged; must be in shared so remote drawer matches) */
.rf-chat-auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 80px;
  padding: 1.25rem 1rem;
}
.rf-chat-auth-loading.rf-hidden {
  display: none !important;
}

/* Chat messages loading state (spinner + "Checking sign-in…" text) */
.rf-chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  min-height: 4rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
}
.rf-chat-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: rf-chat-spin 0.7s linear infinite;
}
@keyframes rf-chat-spin {
  to { transform: rotate(360deg); }
}
.rf-chat-loading-text {
  font-size: 0.8125rem;
}

/* ========== Drawer body & header ========== */
/* Ensure drawer inner and body fill height so chat form stays at bottom (remote + presentation) */
.rf-drawer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.rf-drawer-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
  container-name: rf-drawer-inner;
}
.rf-drawer-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.rf-drawer-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.rf-drawer-tabs {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  gap: 0;
  border: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}
.rf-drawer-tab {
  padding: 0.4rem 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 0;
}
.rf-drawer-tab-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rf-drawer-tab-icon {
  display: none;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  align-items: center;
  justify-content: center;
}
.rf-drawer-tab-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
@container rf-drawer-inner (max-width: 300px) {
  .rf-drawer-tab {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }
}
@container rf-drawer-inner (max-width: 260px) {
  .rf-drawer-tab-label {
    display: none;
  }
  .rf-drawer-tab-icon {
    display: inline-flex;
  }
}
.rf-drawer-tab:hover {
  color: rgba(255, 255, 255, 0.75);
}
.rf-drawer-tab.rf-drawer-tab-active {
  color: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.95);
  border-bottom-color: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.8);
}
.rf-drawer-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1em;
  padding: 0.1em 0.35em;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.85);
  border-radius: 10px;
}
.rf-drawer-tab-badge.rf-hidden {
  display: none;
}
.rf-drawer-tab-notes-indicator {
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.25);
}
.rf-drawer-tab-notes-indicator.rf-drawer-tab-notes-has {
  background: rgba(34, 197, 94, 0.9);
}
.rf-drawer-tab-notes-indicator.rf-drawer-tab-notes-empty {
  background: rgba(255, 255, 255, 0.25);
}
.rf-drawer-header-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.rf-drawer-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.rf-drawer-close:hover {
  background: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.15);
  color: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.95);
}
.rf-drawer-close svg {
  width: 18px;
  height: 18px;
}
.rf-drawer-chat-wrap,
.rf-drawer-notes-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rf-drawer-chat-wrap.rf-hidden,
.rf-drawer-notes-wrap.rf-hidden {
  display: none !important;
}

/* ========== Drawer sign-in (shared: Chat tab + Notes tab, presentation + remote) ========== */
.rf-chat-login {
  padding: 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}
.rf-chat-login.rf-hidden {
  display: none !important;
}
.rf-chat-login-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
}
.rf-chat-login-desc {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
  line-height: 1.45;
}
.rf-chat-login-error {
  font-size: 0.75rem;
  color: #fca5a5;
  margin: 0;
}
.rf-chat-login-error.rf-hidden {
  display: none;
}
.rf-chat-login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 280px;
}
.rf-chat-login-google,
.rf-chat-login-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.rf-chat-login-google {
  background: #fff;
  color: #1f2937;
}
.rf-chat-login-google:hover {
  background: #f3f4f6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.rf-chat-login-github {
  background: #24292e;
  color: #fff;
}
.rf-chat-login-github:hover {
  background: #2f363d;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.rf-chat-login-google:disabled,
.rf-chat-login-github:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
.rf-login-icon-svg {
  width: 1.25em;
  height: 1.25em;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ========== Notes panel ========== */
.rf-notes-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.rf-notes-signin-msg {
  padding: 1rem 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
}
.rf-notes-signin-msg.rf-hidden {
  display: none;
}
.rf-notes-editor-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.5rem 0 0.5rem;
}
.rf-notes-editor-wrap.rf-hidden {
  display: none;
}
.rf-notes-textarea {
  flex: 1;
  min-height: 6rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  box-sizing: border-box;
}
.rf-notes-textarea::-webkit-scrollbar {
  width: 8px;
}
.rf-notes-textarea::-webkit-scrollbar-track {
  background: transparent;
}
.rf-notes-textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  border: 2px solid transparent;
  background-clip: content-box;
}
.rf-notes-textarea:hover::-webkit-scrollbar-thumb,
.rf-notes-textarea:focus::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid transparent;
  background-clip: content-box;
}
.rf-notes-textarea::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
.rf-notes-textarea:focus {
  outline: none;
  border-color: rgba(124, 58, 237, 0.5);
}
.rf-notes-status {
  flex-shrink: 0;
  min-height: 1.25rem;
  display: flex;
  align-items: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  transition: opacity 0.2s ease;
}
.rf-notes-status-text::before {
  content: '';
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  margin-right: 0.3rem;
  vertical-align: 0.15em;
  border-radius: 50%;
  background: transparent;
}
.rf-notes-status.rf-notes-status-saving .rf-notes-status-text::before {
  background: rgba(234, 179, 8, 0.9);
  animation: rf-notes-pulse 1s ease-in-out infinite;
}
.rf-notes-status.rf-notes-status-saved .rf-notes-status-text::before {
  background: rgba(34, 197, 94, 0.9);
}
.rf-notes-status.rf-notes-status-saved-idle {
  opacity: 0.55;
  color: rgba(255, 255, 255, 0.35);
}
.rf-notes-status.rf-notes-status-saved-idle .rf-notes-status-text::before {
  background: rgba(34, 197, 94, 0.5);
}
.rf-notes-status.rf-notes-status-error .rf-notes-status-text::before {
  background: rgba(239, 68, 68, 0.9);
}
@keyframes rf-notes-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========== Chat panel & messages ========== */
.rf-chat-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0 0.5rem 0.5rem;
}
.rf-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.rf-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.rf-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.rf-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.rf-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.rf-chat-msg {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.rf-chat-msg:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}
.rf-chat-msg-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}
.rf-chat-msg-meta-main {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.rf-chat-msg-author {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(167, 139, 250, 0.95);
  flex-shrink: 0;
}
.rf-chat-msg-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.rf-chat-msg-time {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.35);
}
.rf-chat-msg-time-inline {
  align-self: flex-end;
  margin-top: 0.15rem;
}
.rf-chat-msg-text {
  font-size: 0.875rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
  white-space: pre-wrap;
}
.rf-chat-msg-new {
  background: rgba(124, 58, 237, 0.08);
  border-left: 3px solid rgba(124, 58, 237, 0.7);
  padding-left: calc(0.85rem - 3px);
}
.rf-chat-msg-new:hover {
  background: rgba(124, 58, 237, 0.1);
}
.rf-chat-msg-new-pill {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(167, 139, 250, 0.85);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(124, 58, 237, 0.2);
  line-height: 1.2;
  white-space: nowrap;
}
.rf-chat-msg-reply-btn {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.15rem 0.4rem;
  font-size: 0.9rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.rf-chat-msg-reply-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
  color: rgba(196, 181, 253, 0.95);
}
.rf-chat-msg-delete-btn {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.15rem 0.4rem;
  font-size: 0.9rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.rf-chat-msg-delete-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}
.rf-chat-msg-reply-quote {
  font-size: 0.75rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.5);
  border-left: 2px solid rgba(124, 58, 237, 0.5);
  padding: 0.25rem 0 0.25rem 0.5rem;
  margin-top: 0.2rem;
  margin-bottom: 0.15rem;
  word-break: break-word;
  white-space: pre-wrap;
}
.rf-chat-msg-version-remark {
  display: block;
  font-size: 0.6875rem;
  font-style: italic;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.35rem;
}

/* Delete confirmation */
.rf-chat-delete-confirm {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  animation: rf-fade-in 0.12s ease-out;
}
@keyframes rf-fade-in { from { opacity: 0; } to { opacity: 1; } }
.rf-chat-delete-dialog {
  background: #1e1e2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  min-width: 200px;
  max-width: 260px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.rf-chat-delete-text {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}
.rf-chat-delete-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
.rf-chat-delete-cancel,
.rf-chat-delete-ok {
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.rf-chat-delete-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}
.rf-chat-delete-cancel:hover {
  background: rgba(255, 255, 255, 0.14);
}
.rf-chat-delete-ok {
  background: rgba(239, 68, 68, 0.8);
  color: #fff;
}
.rf-chat-delete-ok:hover {
  background: rgba(239, 68, 68, 1);
  transform: scale(1.03);
}

/* Reply preview & form */
.rf-chat-reply-preview {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.25rem;
  border-radius: 8px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.25);
}
.rf-chat-reply-preview.rf-hidden {
  display: none;
}
.rf-chat-reply-preview-text {
  flex: 1;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rf-chat-reply-preview-cancel {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.rf-chat-reply-preview-cancel:hover {
  background: rgba(0, 0, 0, 0.3);
}

.rf-chat-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.5;
}
.rf-chat-loading {
  padding: 2rem 1rem;
}

.rf-chat-form {
  flex-shrink: 0;
  margin-top: 0;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.4rem;
}
.rf-chat-form .rf-chat-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  min-height: 36px;
  max-height: 100px;
  padding: 0.45rem 0.75rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-size: 0.8125rem;
  line-height: 1.35;
  resize: none;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.rf-chat-form .rf-chat-input::-webkit-scrollbar {
  width: 8px;
}
.rf-chat-form .rf-chat-input::-webkit-scrollbar-track {
  background: transparent;
}
.rf-chat-form .rf-chat-input::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  border: 2px solid transparent;
  background-clip: content-box;
}
.rf-chat-form .rf-chat-input:hover::-webkit-scrollbar-thumb,
.rf-chat-form .rf-chat-input:focus::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.4);
  border: 2px solid transparent;
  background-clip: content-box;
}
.rf-chat-form .rf-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
.rf-chat-form .rf-chat-input:focus {
  outline: none;
  border-color: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.6);
  box-shadow: 0 0 0 2px rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.12);
}
.rf-chat-form .rf-chat-send {
  flex-shrink: 0;
  height: 36px;
  padding: 0 0.85rem;
  border-radius: 18px;
  border: none;
  background: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.9);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.2s ease, transform 0.15s ease;
}
.rf-chat-form .rf-chat-send:hover {
  background: rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 1);
  transform: translateY(-1px);
}
.rf-chat-form .rf-chat-send:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--notes-tts-highlight-rgb, 124, 58, 237), 0.4);
}
.rf-chat-form-error {
  flex-basis: 100%;
  font-size: 0.7rem;
  color: #fca5a5;
  margin-top: 0.15rem;
}

.rf-chat-presence {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
}

/* Stacked drawer bottom clearance: see lectura-next `base.css` — `.rf-drawer-body` padding when `.rf-layout-stacked .rf-drawer.rf-open` (all tabs). */
