/* Override body padding for full-screen mode */
body.rh-page {
  padding-top: 0;
  overflow: hidden;
}
body.rh-page .container {
  padding: 0;
  max-width: none;
  height: 100vh;
}

/* === Full-screen wrap === */
.rh-wrap {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 240px 360px 1fr;
  background: var(--bg);
  z-index: 1;
}

.rh-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* === Sidebar === */
.rh-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.rh-sidebar-head {
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.rh-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.rh-logo svg { width: 15px; height: 15px; }

.rh-brand {
  font-weight: 800;
  font-size: 1rem;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: -0.01em;
}

.rh-section-label {
  padding: 0.85rem 1.1rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.rh-folders {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem 0.5rem;
}

.rh-folders::-webkit-scrollbar { width: 4px; }
.rh-folders::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.rh-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.55rem 0.75rem;
  margin: 1px 0;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.rh-folder:hover {
  background: var(--surface-hover);
  color: var(--text-bright);
}

.rh-folder.active {
  background: var(--surface-hover);
  color: var(--text-bright);
  font-weight: 700;
}

.rh-folder.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--gradient-primary);
  border-radius: 0 2px 2px 0;
}

.rh-folder-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
}

.rh-folder-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rh-folder-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background: var(--gradient-primary);
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.rh-sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem;
  flex-shrink: 0;
}

.rh-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}

.rh-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
  animation: rhPulse 2s ease-in-out infinite;
}

.rh-status.error .rh-status-dot {
  background: var(--red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
  animation: none;
}

.rh-status.connecting .rh-status-dot {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  animation: none;
}

@keyframes rhPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.rh-user-email {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: ui-monospace, "Fira Code", monospace;
  word-break: break-all;
  line-height: 1.4;
  margin-bottom: 0.55rem;
}

.rh-actions {
  display: flex;
  gap: 5px;
}

.rh-btn-sm {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.rh-btn-sm:hover {
  border-color: var(--border-hover);
  color: var(--text-bright);
}

.rh-btn-sm.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.rh-btn-sm svg { width: 11px; height: 11px; }

/* === List Pane === */
.rh-list {
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.rh-list-head {
  padding: 0.85rem 1rem 0.55rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rh-list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  gap: 8px;
}

.rh-list-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}

.rh-list-actions {
  display: flex;
  gap: 5px;
}

.rh-act {
  padding: 0.32rem 0.65rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.rh-act:hover {
  border-color: var(--border-hover);
  color: var(--text-bright);
}

.rh-act.on {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
}

.rh-refresh {
  padding: 0.32rem 0.85rem;
  background: var(--gradient-primary);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.rh-refresh:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
}

.rh-pagination {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rh-page-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rh-page-btn:hover:not(:disabled) {
  border-color: var(--indigo);
  color: var(--indigo);
}

.rh-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.rh-page-info {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 6px;
}

.rh-page-total {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: auto;
}

.rh-search {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rh-search-input {
  width: 100%;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  color: var(--text-bright);
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rh-search-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.rh-search-input::placeholder { color: var(--text-dim); }

.rh-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
}

.rh-list-scroll::-webkit-scrollbar { width: 4px; }
.rh-list-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Skeleton */
.rh-skel {
  padding: 0.65rem 0.8rem;
  margin-bottom: 2px;
  border-radius: 10px;
}
.rh-skel-line {
  height: 10px;
  background: linear-gradient(90deg, var(--surface-hover) 0%, var(--border) 50%, var(--surface-hover) 100%);
  background-size: 200% 100%;
  border-radius: 4px;
  animation: rhShimmer 1.4s ease-in-out infinite;
  margin-bottom: 6px;
}
.rh-skel-line.short { width: 40%; }
.rh-skel-line.medium { width: 70%; }
@keyframes rhShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.rh-item {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  margin-bottom: 2px;
  position: relative;
  border: 1px solid transparent;
}

.rh-item:hover {
  background: var(--surface-hover);
  transform: translateX(2px);
}

.rh-item.active {
  background: var(--surface-hover);
  border-color: var(--indigo);
}

.rh-item.unread .rh-from { color: var(--text-bright); font-weight: 700; }
.rh-item.unread .rh-subj { color: var(--text-bright); font-weight: 600; }

.rh-item.unread::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-primary);
  border-radius: 0 3px 3px 0;
}

.rh-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  gap: 8px;
}

.rh-from {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.rh-date {
  font-family: ui-monospace, "Fira Code", monospace;
  font-size: 0.68rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.rh-subj {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rh-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 2.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.rh-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.85rem;
}

.rh-empty-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--text-dim);
  fill: none;
  stroke-width: 1.5;
}

/* === Detail Pane === */
.rh-detail {
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.rh-detail-toolbar {
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  flex-shrink: 0;
}

.rh-view-toggle { display: flex; gap: 5px; }

.rh-vt {
  padding: 0.32rem 0.75rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.rh-vt.active {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
}

.rh-shortcuts-hint {
  font-size: 0.65rem;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  font-family: ui-monospace, "Fira Code", monospace;
}

.rh-shortcuts-hint kbd {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.65rem;
  font-family: inherit;
  margin-right: 3px;
}

.rh-detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

.rh-detail-scroll::-webkit-scrollbar { width: 4px; }
.rh-detail-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.rh-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
}

.rh-detail-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.rh-detail-empty-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--text-dim);
  fill: none;
  stroke-width: 1.5;
}

.rh-subject {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 1.1rem;
  word-break: break-word;
  letter-spacing: -0.02em;
}

.rh-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.rh-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
}

.rh-meta-info { flex: 1; min-width: 0; }
.rh-meta-from { font-size: 0.88rem; font-weight: 700; margin-bottom: 2px; word-break: break-word; }
.rh-meta-date { font-family: ui-monospace, "Fira Code", monospace; font-size: 0.72rem; color: var(--text-dim); }

.rh-iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.rh-body-text {
  white-space: pre-wrap;
  font-family: ui-monospace, "Fira Code", monospace;
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text-bright);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
}

/* === Login === */
.rh-login {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  max-width: calc(100vw - 2rem);
  padding: 2.25rem 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.15);
  z-index: 50;
}

.rh-login::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 1px;
  background: var(--gradient-primary);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.4;
  pointer-events: none;
}

.rh-login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.rh-login-logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.rh-login-logo-icon svg { width: 22px; height: 22px; }

.rh-login-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.rh-login-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.rh-form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  margin-top: 0.85rem;
}

.rh-form-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-bright);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rh-form-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.rh-form-input::placeholder { color: var(--text-dim); }

.rh-login-btn {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.rh-login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); }
.rh-login-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.rh-login-error {
  margin-top: 0.85rem;
  font-size: 0.78rem;
  color: var(--red);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  display: none;
}

/* Spinner */
.rh-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  color: var(--indigo);
}

.rh-spinner svg {
  animation: spin 0.8s linear infinite;
}

/* Toast */
.rh-toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-primary);
  color: white;
  padding: 0.55rem 1.4rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  animation: rhToastIn 0.25s ease;
}

@keyframes rhToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Responsive */
@media (max-width: 1024px) {
  .rh-wrap {
    grid-template-columns: 200px 300px 1fr;
  }
  .rh-shortcuts-hint { display: none; }
}

@media (max-width: 768px) {
  .rh-wrap {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .rh-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 160px;
  }
  .rh-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 280px;
  }
  .rh-section-label { display: none; }
}